Brains2b.ORG

SquelerDDL 1.01

stable

component

SquelerDDL is a convenient way to generate SQL Data Definition statements for different databases from the information obtained from meta data.

Full description

SquelerDDL tries to generate the SQL statements as close to SQL-92 as possible and use the correct types for the database data types as it can, but this is an ongoing struggle for different JDBC drivers and the way meta-data was implemented in these drivers. So if you find any problems please report them.

Files
namedatezipzip (source)tar.gztar.gz (source)
SquelerDDL 1.0125-09-2007SquelerDDL-1.01.zipSquelerDDL-src-1.01.zipSquelerDDL-1.01.tar.gzSquelerDDL-src-1.01.zip

Note: If you want to make a quick start download the .zip or .tar.gz file. It includes the compiled jar and possible dependencies. The sources contains the sources for this specific project and the compiled libraries listed as dependencies.

Dependencies

language:

java 1.4+

Using SquelerDDL

How to use

Given that you have a database connection to the dutch/lion test tables, you can use SquelerDDL as simple as:

	SQLMetaData meta = new SQLMetaData(getConnection());
	List l = meta.getTablesWithColumns(null,"DUTCH","COURSE");
	if (l!=null) {
		TableModel model = (TableModel) l.get(0);
		TableDDL ddl = new TableDDL (model);
		ddl.setAction(TableDDL.CREATE);
		System.out.println(ddl.getStatement());
	}
	
The output in (this case for Oracle) will look like:
	CREATE TABLE COURSE(
		ID NUMBER(9) NOT NULL,
		NAME VARCHAR2(50) NOT NULL,
		TEACHER NUMBER(9),
		STARTDATE DATE,
		ENDDATE DATE,
		DAYOFWEEK NUMBER(1) NOT NULL,
		STARTTIME NUMBER(4) NOT NULL,
		ENDTIME NUMBER(4) NOT NULL,
		ROOM NUMBER(9))
	;
	

Another way to use it is creating your own model

	ColumnDDL ddl = new ColumnDDL();
	ddl.setTableName("COURSE");
	ddl.setName("TEACH_ASST");
	ddl.setDataType(java.sql.Types.VARCHAR);
	ddl.setTypeName("VARCHAR2"); // You can look this up via SQLMetaData, if you already have a valid database connection 
	ddl.setColumnSize(32);
	ddl.setAction(ColumnDDL.CREATE);
	System.out.println(ddl.getStatement());		
	
The output in this case for Oracle will look like:
	ALTER TABLE COURSE ADD COLUMN TEACH_ASST VARCHAR2(32);
	

releases

SquelerDDL 1.01

  • Waldorf cleanup
  • Use Changes from new Squeler 1.02 implementation
  • Implemented Constraints (FOREIGN, PRIMARY and CHECK) correctly
  • Added wrapper for packages, procedures and functions

SquelerDDL 0.10

  • Initial creation