{
XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
XTablesSupplier.class, _forConnection );
XDataDescriptorFactory tableDescFac = (XDataDescriptorFactory)UnoRuntime.queryInterface(
XDataDescriptorFactory.class, suppTables.getTables() );
XPropertySet tableDesc = tableDescFac.createDataDescriptor();
try
{
tableDesc.setPropertyValue( "Name", getName() );
}
catch ( Exception e ) { e.printStackTrace( System.err ); }
XColumnsSupplier suppDescCols = (XColumnsSupplier)UnoRuntime.queryInterface(
XColumnsSupplier.class, tableDesc );
XNameAccess descColumns = suppDescCols.getColumns();
XDataDescriptorFactory columnDescFac = (XDataDescriptorFactory)UnoRuntime.queryInterface(
XDataDescriptorFactory.class, descColumns );
HsqlColumnDescriptor[] myColumns = getColumns();
for ( int i = 0; i < myColumns.length; ++i )
{
XPropertySet columnDesc = columnDescFac.createDataDescriptor();
try
{
columnDesc.setPropertyValue( "Name", myColumns[i].getName() );
columnDesc.setPropertyValue( "IsNullable", new Integer( myColumns[i].isRequired() ? ColumnValue.NO_NULLS : ColumnValue.NULLABLE) );
columnDesc.setPropertyValue( "TypeName", myColumns[i].getTypeName() );
if ( myColumns[i].isPrimaryKey() || myColumns[i].isForeignKey() )
// not yet implemented
throw new java.lang.UnsupportedOperationException("creating a primary or foreign key via SDBCX not yet implemented" );
}
catch( com.sun.star.uno.Exception e ) { e.printStackTrace( System.err ); }