Whole document tree 9 - JDBC-ODBC Bridge Driver9.1 Obtaining a JDBC DriverIt is recommended that you obtain a commercial JDBC driver from a vendor such as your database vendor or your database middleware vendor. Check the list of drivers currently available.The JDBC-ODBC Bridge driver is recommended only for experimental use or when no other alternative is available. 9.2 JDBC-ODBC BridgeIf 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).The JDBC-ODBC Bridge driver is recommended for use in prototyping efforts and for cases where no other JDBC technology-based driver exists. If a commercial, all-Java JDBC driver is available, we recommend that it be used instead of the Bridge. 9.2.1 What Is the JDBC-ODBC Bridge?The JDBC-ODBC Bridge is a JDBC driver that 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 thesun.jdbc.odbc Java package
and contains a native library used to access ODBC. The Bridge is a joint
development of Merant and Java Software.
9.2.2 ODBC Compatibility and ODBC Versions SupportedOn Solaris, the JDBC 2.0 bridge must be used with an ODBC 3.x driver manager. The bridge supports both ODBC 2.x and ODBC 3.x drivers, but has been tested with only ODBC 3.x drivers. On NT, the JDBC 2.0 bridge supports the ODBC 2.x and ODBC 3.x driver manager and drivers. The JDBC 2.0 bridge has been tested only with an ODBC 3.x driver manager and with both ODBC 2.x and 3.x drivers. Merant recommends that the JDBC 2.0 bridge be used with version 3.5 or higher of Merant's DataDirect ODBC drivers. 9.2.3 The Bridge ImplementationThe Bridge is implemented in Java and uses Java native methods to call ODBC.9.2.4 InstallationThe Bridge is installed automatically with the Java 2 SDK, Standard Edition, as packagesun.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.
9.3 Using the BridgeThe Bridge is used by opening a JDBC connection using a URL with theodbc 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. 9.3.1 Using the Bridge from an AppletJDBC used with a Pure Java JDBC driver works well with applets. The Bridge driver does not work well with applets.9.3.2 Most Browsers Do Not Support the BridgeSince the Bridge is an optional component of the Java 2 SDK, Standard Edition, 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.9.3.3 Tested ConfigurationsFrom Solaris, we have used the Bridge to access Oracle 8.1.5 using version 3.5 of Merant's ODBC drivers. From NT, we have used the Bridge to access SQL Server 6.x using the latest ODBC driver from Microsoft.9.3.4 ODBC Drivers Known to Work with the BridgeODBC drivers are available for Oracle, Sybase, Informix, Microsoft SQL Server, and Ingres. The MERANT ODBC driver suite should be completely compatible with the JDBC-ODBC Bridge. To evaluate or purchase MERANT ODBC drivers, please contact MERANT DataDirect Sales at 1-800-547-4000 Option 2 or via the World Wide Web athttp:\\www.merant.com .
The MS SQL Server driver has also been used successfully on NT. Many other
ODBC drivers will likely work.
9.3.5 What Is the JDBC URL Supported by the Bridge?The Bridge driver uses theodbc subprotocol. URLs for this subprotocol are of the
form:
For example:
jdbc:odbc:sybase jdbc:odbc:mydb;UID=me;PWD=secret jdbc:odbc:ora123;Cachesize=300 9.3.6 DebuggingThe Bridge provides extensive tracing whenDriverManager tracing is enabled. The
following line of code enables tracing and sends it to standard out:
java.sql.DriverManager.setLogStream(java.lang.System.out);
9.4 New JDBC 2.0 API Features Supported by the BridgeThe JDBC-ODBC Bridge driver in this release supports the following new features in the JDBC 2.0 API:
The current release of the Bridge supports multi-threaded ODBC drivers
and contains numerous bug fixes.
[Top] [Prev] [Next] jdbc@wombat.eng.sun.com or jdbc-odbc@wombat.eng.sun.com Copyright © 1996 - 1999 Sun Microsystems, Inc. All rights reserved. |