Using JDBC to Create Database Objects
By James W. Cooper2003-05-24
Building a Database Object, A Visual Database Program
To wrap up the material we've covered in this chapter, let's write a simple GUI program which allows us to display the table names, column names, and column contents of a database. We'll also include a text area where you can type in an SQL query to execute on that Database. You will find the resultSet and Database classes used in this program, called dbFrame.java, in the \chapter20 subdirectory on the Companion CD-ROM. The display of the program is shown in Figure 3.
Figure 3: The dbFrame.java program for displaying data in a JDBC-connected database
In this program, the table names of our default database, groceries.mdb, are shown in the left column. When you click on one of the table names, the column names are shown in the middle column. Finally, when you click on a row in the middle column, the contents of that column are shown in the right-hand column.
|
Tutorial Pages:
» What is a Database?
» Getting Data out of Databases
» Kinds of Databases
» ODBC
» What Is JDBC?
» Installing and Using JDBC
» Types of JDBC Drivers
» Two-Tier and Three-Tier Models
» Writing JDBC Code to Access Databases
» Registering Your Database with ODBC
» Connecting to a Database
» Accessing the Database
» The ResultSet
» ResultSetMetaData
» DatabaseMetaData
» Getting Information on Tables
» Executing SQL Queries, Printing out ResultSets, A Simple JDBC Program
» Building Higher Level JDBC Objects
» Building a Database Object, A Visual Database Program
» Executing a Query
» The Query Result Dialog
» Example Files
» Summary
First published by IBM DeveloperWorks
