Jenny the database code generator - Tutorial
A Jenny generated file
Other ways to run Jenny include:
From your IDE:
From an icon on your Windows desktop:
In a build script, Ant script, or batch file:
Now that you've created your "personalized" files, you are ready to use them.
You should be able to see a Java source file for each of your tables
in your database. Compile and use the generated source as if you wrote it yourself!
Let's say that you have a database named "rentals".
Within the rentals database you have tables named "videos",
"compactDisks", "booksOnTape". After you run Jenny, you should see a
subdirectory named rentals (the subdirectory is defined by the
properties file) which contains classes named "Videos",
"CompactDisks", and "BooksOnTape".
Each of these classes contains methods with the same signature as the
methods in DBFacade, which have been overridden.
Now you can create a method in your code like:
// pass in an serial number and get back
// the title of the video that you are searching for.
private String getVideoTitle( int serialNumber )
return VideosTable.getRow( serialNumber ).getTitle();
and you won't have to worry about getting the wrong thing back because
someone changed the name of the column from "Title" to "Titles" or "TITLE" or
having to change the code in the getTitle() method from
out.print( rs.getString( "Title" ) );
out.print( rs.getString( "Titles" ) );
everywhere you've used that column name.
For more examples of how to use the files that Jenny generated,
A sample properties file.
VideosTable.java file that was created from the "videos" table by Jenny
An entire program that adds one record and then reads and shows that record.
Page maintained by
Marilyn de Queiroz