Java Reference
In-Depth Information
Finally, you can execute the update itself.
sqlStmt.executeUpdate();
You could execute the same statement repeatedly with different values simply
by setting the parameters to new values and calling the executeUpdate() method.
Closing the statement would release the statement; and the statement could not be
executed again without going through the preparation process. This same logic can
be applied to inserting or deleting rows from a table.
C ONFIGURING THE JDBC-ODBC B RIDGE
The JDBC-ODBC Bridge may be an option for you if you do not have a JDBC dri-
ver and database and you want to experiment with JDBC. As mentioned previously,
the bridge is not desirable for production situations. It carries high overhead and is
not fully supported.
The bridge is useful for prototyping and educational purposes if you are devel-
oping on a Windows platform. The driver itself comes with the Java SDK. If you
have any database with an ODBC driver, you can access it from Java code using the
JDBC-ODBC Bridge.
To use the JDBC-ODBC Bridge, follow these steps:
1. Open up the Control Panel from the Settings menu selection on the Start
menu.
2. Find the ODBC Data Sources Administrator icon and double-click it. This
may be located in the Administrative Tools folder. You should see a list of
data sources that have been configured.
3. If you need to add a new data source, click the Add button. You should see
a list of ODBC drivers that are installed on your system.
4. Select a driver that supports the database you wish to access through Java.
For example, select Microsoft Access Driver.
5. The next dialog box varies by driver. You should supply a data source
name, which is the logical name by which the database will be known. If
you would like to use the code in the example class without any changes,
name the data source “mydatasource.” You may also supply a description
of the data source if you want. The Microsoft Access Setup requires you to
select a database or to create a new one. For this exercise, select the file
named mydatabase.mdb.
6. Once you have completed the setup, the new data source you configured
should appear in the master list of data sources.
Search WWH ::




Custom Search