If possible, use a Pure Java JDBC driver instead of the Bridge and an ODBC driver.
This completely eliminates the client configuration required by ODBC. It also eliminates the potential that the Java VM could be corrupted by an error in the native
code brought in by the Bridge (that is, the Bridge native library, the ODBC driver
manager library, the ODBC driver library, and the database client library).
10.1.1 What Is the JDBC-ODBC Bridge?
The JDBC-ODBC Bridge is a JDBC driver which implements JDBC operations by
translating them into ODBC operations. To ODBC it appears as a normal application program. The Bridge implements JDBC for any database for which an ODBC
driver is available. The Bridge is implemented as the sun.jdbc.odbc Java package
and contains a native library used to access ODBC. The Bridge is a joint development of Intersolv and JavaSoft.
10.1.2 What Version of ODBC Is Supported?
The bridge supports ODBC 2.x. This is the version that most ODBC drivers currently support. It will also likely work with most forthcoming ODBC 3.x drivers;
however, this has not been tested.
10.1.3 The Bridge Implementation
The Bridge is implemented in Java and uses Java native methods to call ODBC.
10.1.4 Installation
The Bridge is installed automatically with the JDK as package sun.jdbc.odbc. See
your ODBC driver vendor for information on installing and configuring ODBC. No
special configuration is required for the Bridge. See your database vendor for client
installation and configuration information. On Solaris, some ODBC driver managers name their libs libodbcinst.so and libodbc.so. The Bridge expects these
libraries to be named libodbcinst.so.1 and libodbc.so.1, so symbolic links for
these names must be created.
10.2 Using the Bridge
The Bridge is used by opening a JDBC connection using a URL with the odbc subprotocol. See below for URL examples. Before a connection can be established, the
bridge driver class, sun.jdbc.odbc.JdbcOdbcDriver, must either be added to the
java.lang.System property named jdbc.drivers, or it must be explicitly loaded
using the Java class loader. Explicit loading is done with the following line of code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
When loaded, the ODBC driver (like all good JDBC drivers) creates an
instance of itself and registers this with the JDBC driver manager.
10.2.1 Using the Bridge from an Applet
JDBC used with a Pure Java JDBC driver works well with applets. The Bridge
driver does not work well with applets.
10.2.2 Most Browsers Do Not Support the Bridge
Since the Bridge is an optional component of the JDK, it may not be provided by a
browser. Even if it is provided, only trusted applets (those allowed to write to files)
will be able to use the Bridge. This is required in order to preserve the security of the
applet sandbox. Finally, even if the applet is trusted, ODBC and the DBMS client
library must be configured on each client.
10.2.3 Tested Configurations
From Solaris, we have used the Bridge to access Oracle 7.1.6 and Sybase Version 10
running on Solaris. From NT, we have used the Bridge to access SQL Server 6.x.
10.2.4 ODBC Drivers Known to Work with the Bridge
Visigenic provides ODBC drivers which have been tested with the the Bridge. Drivers are available for Oracle, Sybase, Informix, Microsoft SQL Server, and Ingres. To
purchase the ODBC DriverSet 2.0, please contact Visigenic sales at 415-312-7197,
or visit the web site www.visigenic.com. The INTERSOLV ODBC driver suite
should be completely compatible with the JDBC-ODBC Bridge. The following
drivers have successfully passed a minimal test suite: Oracle, xBASE, Sybase (Windows NT/95 only), Microsoft SQL-Server, and Informix. To evaluate or purchase
INTERSOLV ODBC drivers, please contact INTERSOLV DataDirect Sales at 1-
800-547-4000 Option 2 or via the World Wide Web at http:\\www.intersolv.com.
The MS SQL Server driver has also been used successfully on NT. Many other
ODBC drivers will likely work.
10.2.5 ODBC Driver Incompatibilities
On Solaris, we have found that the Sybase ctlib-based drivers don't work because
ctlib has a signal-handling conflict with the Java VM. This is likely not a problem on
NT due to differences in the NT Java VM; however, this has not been verified. Some
ODBC drivers only allow a single result set to be active per connection.
10.2.6 What Is the JDBC URL Supported by the Bridge?
The Bridge driver uses the odbc subprotocol. URLs for this subprotocol are of the
form:
jdbc:odbc:<data-source-name>[<attribute-name>=<attribute-value>]*
For example:
The Bridge assumes that ODBC drivers are not reentrant. This means the Bridge
must synchronize access to these drivers. The result is that the Bridge provides limited concurrency. This is a limitation of the Bridge. Most Pure Java JDBC drivers
provide the expected level of concurrent access.