I'm not including the actual applet in this page, because it probably won't work on your browser, but feel free to download the source and build it yourself.
An explanatory note:
All of the JDBC-specific stuff is contained
in the queryFrame class; the other two classes above are very simple
drivers that simply create an instance of this class.
A further note:
This stuff was built using the JDBC-ODBC bridge. You'll
need to install the JDBC-ODBC bridge software for it to work correctly,
and it only works against ODBC data sources registered on your system.
Even then, I'm not sure if it will work as an applet downloaded from
this page; it works in Appletviewer, though. So don't get bent out
of shape if you get "no suitable driver" messages. Hopefully, this
JDBC-ODBC kludge will largely go away once a full-blown JDBC is
released with JDK 1.1. When this release happens, I'll rework this
applet.
Yet another note:
This is not intended to be a full-featured application; I intend for
it to be used to illustrate the basic JDBC mechanisms for opening a
database connection, executing a query, and handling a results set.
Not a lot of bells and whistles involved, but I think it nicely illustrates
the basics of what you need to do in order to execute SQL queries from
Java. You'll want to have a java console open when running this, because
it writes exception messages to the console.