This page hosts a couple complete samples I did for the book Teach Yourself Database Programming With Visual J++ in 21 Days from Sams press. The book is out of print, so I no longer keep a complete collection of updated samples online.
Neither of these samples is particularly "finished" - they are meant to demonstrate principles and techniques. But both are quite usable, if somewhat out of date. At any rate, you are welcome to them!
And while we're on the subject of Java, might I recommend JPython - a 100% pure Java implementation of Python. You can even subclass from Java classes. It is particularly valuable technique for prototyping and learning the API of Java package.
Query Maker is tool for developing queries the "old-fashioned" way - by hand.
You can connect to any database you have drivers for (and choose the driver to use).
It lets you see what built-in functions the driver has.
It lets you select tables and columns from the database, and it maintains a history list of the queries you've tried - making it very easy to refine a query.
It launches a standalone Frame window for every result set which is dynamically formatted according to the result set. You can even save a text listing of the result set.
I developed Query Maker because of the shortage of good query tools.
Visual query tools are fine for quick exploration of a database, but there's no substitute for developing and testing SQL by hand.
With all the myths about how databases optimize SQL, you might be surprised to learn that simply reordering the conditions in a WHERE clause can make an enormous difference in a query's execution time.
Try doing that in a visual query tool!
Download Query Maker
When QueryMaker starts, File | Connect brings up the Signon Dialog.
Type the full name of the driver you intend to use into the bottom edit box and click Add.
If the driver name moves into the Registered box, QueryMaker was able to load the driver.
Then enter the database's URL into the topmost edit box, and enter the user and password, if necessary.
You can add further parameters to the database open in the parameters edit box.
Click OK, and you should be connected.
Please note - if you are using QueryMaker to connect to Access, the Tables dialog will not work - Access does not use the normal ANSI SQL syntax for listing the tables available in the database.
This sample creates a server that sits between the clients and the database.
It holds open a number of connections to the database, and threads client requests through them, (for Access, use one connection; for other databases, use however many you'll need for performance).
It uses a very simple, easily modified protocol for talking to clients.
Essentially, it uses canned queries, each of which is identified by a short integer.
The client sends in the identifier of the query (or update) it wants executed, and any parameters to that query.
The server spawns a thread for the client request.
The thread waits until a database connection becomes available, then executes the query.
The first thing back to the client is a return code.
If this is "OK", it is followed by the result set.
You write the queries (and the code that transmits the result set).
If you use the sample code as a template, you might have to change a dozen lines of code.
The client is up to you. The sample provides a "testing" client, but it's intended to exercise the server, not provide any kind of user interface.
The client could live in an applet, but when I've used this code, the "clients" were actually CGI scripts. Using it this way solves a number of problems with doing database access from CGI: the overhead involved in making new connections to the database, and controlling the number of simultaneous connections you have (which could be a licensing issue).
Download Database Server