Running the SQL2JAVA example

The SQL2JAVA example can be run in less than five minutes. It generates a DB layer API to access a simple database schema (on hsql), Javadoc, and more!

Minimum requirements

We assume Java and Ant have already been installed.

Run it yourself in less than 5 minutes

  1. Open a console, and go to sql2java home directory.
  2. Now from this console, start the hsql server (we use hsql only to run the example):
    ant hsql.server


    NOTE: In Windows, type
    START ant hsql.server
    to keep hsql running in the background and immediately access a new command console.)
  3. Open another console, go to sql2java home directy and create the sample database schema:
    ant database.create
  4. Generate the Java API for accessing the sample database:
    ant generate
  5. Take a look at the generated source code API
  6. Now, compile the generated source code:
    ant compile
  7. We wrote a sample program that uses the generated API, you can run it now:
    ant run
  8. Don't forget to generate the Javadoc:
    ant javadoc
  9. Try sql2java against your own schema. Take a look at sql2java.properties; it is self documented (you must edit at least section 1/8 and 2/8)
  10. If you need to customize the generated code, edit sql2java templates: And if you think your patch could be useful to others, please share your work...
  11. You can also add your own templates...
  12. Enjoy!