Brains2b.ORG

Sql2Class 1.01

stable

application

Makes data classes and data class control objects from database tables

Full description

Sql2Class is a console application which generates data objects (bean-like classes) from a TABLE which is accessible through a JDBC connection. It also provides the DataC control classes for these tables supplying an easy, low-maintenance way of interacting with a database.

Files
namedatezipzip (source)tar.gztar.gz (source)
Sql2Class 1.0113-04-2008Sql2Class-1.01.zipSql2Class-src-1.01.zipSql2Class-1.01.tar.gzSql2Class-src-1.01.tar.gz
Sql2Class 0.30.127-08-2004Sql2Class-0.30.1.zipSql2Class-0.30.1.tar.gz
Sql2Class 0.3004-11-2003Sql2Class-0.30.zipSql2Class-0.30.tar.gz

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+

Used components

Used libraries

Limits

To Do

Known Issues

  • Sql2ClassConsole should support reading the classpath property

Using Sql2Class

How to use

You can run Sql2Class straight from the command prompt. Just go to the directory you have installed it in and run:

java -Xbootclasspath/a:[JDBC-driver.jar] -jar Sql2Class.jar -d [DriverClassName] -r [URLConnectionString] -u [Username] -p [Password] -t [Table]

For example:
java -Xbootclasspath/a:/usr/java/lib/classes12.zip -jar Sql2Class.jar -d oracle.jdbc.driver.OracleDriver -r jdbc:oracle:thin:@db.acme.com:1521:ora -u scott -p tiger -t EMP

To make life a little bit easier I usually put the driver, url, user, location and package in a sql2class.properties file placed in the same directory:

driver=oracle.jdbc.driver.OracleDriver
url=jdbc\:oracle\:thin\:@db.acme.com\:1521\:ora
user=scott
location=/project/AcmeApp/src
package=com.acme.app.data
and run it like this: java -Xbootclasspath/a:/usr/java/lib/classes12.zip -jar Sql2Class.jar -t EMP -p tiger
You could define all parameters in the sql2class.properties

Look for all the parameters you can define with Sql2Class at the description of Sql2ClassConsolein the javadoc

Note: -Xbootclasspath/a: is used to add the JDBC driver to the classpath and still be able to run it from the jar file. It doesn't seem possible to add additional classpath information to a runnable jar file. An alternative for this would be:
java -cp [JDBC-driver.jar]:Sql2Class.jar org.brains2b.sql.toclass.Sql2ClassConsole -d [DriverClassName] -r [URLConnectionString] -u [Username] -p [Password] -t [Table]

Reference implementation/examples

  • Track 0.20+

releases

Sql2Class 1.01

  • Waldorf changes
  • Support for Clob/Blob/Stream in generating classes

Sql2Class 0.30.1

  • Just fixed the layout of the comparison classes used in the unit test to comply with the new version of TypeWriter
  • Manifest.mf did not contain proper classpath

Sql2Class 0.30

  • Rewrote sql2class to use TypeWriter instead of PrintWriter directly
  • Check that no keywords are accidentally used as variable name

Sql2Class 0.24

  • Fixed problems with optimistic locking