|
|
|
|
Re: again on Data Tools api / extensions. How to write on DB using DTP objects. [message #596704 is a reply to message #491504] |
Thu, 15 October 2009 03:45  |
Eclipse User |
|
|
|
Thanks for the answer.
I arrived at the point where I create Sql Code to create a table on an existing schema (so... ready to be executed by a java.sql.statement).
The code is here...
ConnectionInfo connectionInfo = (ConnectionInfo) managedConnection.getConnection().getRawConnection();
database = connectionInfo.getSharedDatabase();
SQLQueryParserFactory factory = new SQLQueryParserFactory();
testSchema = factory.createSchema("test");
testSchema.setDatabase(database);
SQLTablesFactory tablesFactory = new SQLTablesFactoryImpl();
PersistentTable persistentTable = tablesFactory.createPersistentTable();
persistentTable.setName("tabletestN1");
persistentTable.setSchema(testSchema);
Column column = tablesFactory.createColumn();
column.setName("testcolumn");
DatabaseDefinition def = DatabaseDefinitionRegistryImpl.INSTANCE.getDefinition(databa se);
PredefinedDataType predefineDatatype = def.getPredefinedDataType("INTEGER");
column.setDataType(predefineDatatype);
column.setNullable(false);
column.setTable(persistentTable);
DDLGenerator dDLGenerator = new GenericDdlGenerator();
String[] generateSql = dDLGenerator.createSQLObjects(new SQLObject[]{persistentTable}, true, true, null);
I spent 3 days looking for a way in the DTP's java source files.
In this way I can say that you work ALWAYS offline, until you don't execute the Sql code
|
|
|
Powered by
FUDForum. Page generated in 0.04286 seconds