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]