![]() |
JDBCTM-ODBC Bridge Enhancements |
Documentation Contents
JDBC |
The JDBC-ODBC Bridge allows applications written in the
JavaTM programming language to use the
JDBCTM API with many existing
ODBC drivers. The Bridge is itself a driver based on JDBC technology
("JDBC driver") that is defined in the class
sun.jdbc.odbc.JdbcOdbcDriver
. The Bridge defines the JDBC
subprotocol odbc
.
The JDBC-ODBC Bridge should be considered a transitional solution. Sun Microsystems and Merant are working to make the Bridge more reliable and robust, but they do not consider it a supported product. With the development of pure-Java JDBC drivers, the JDBC-ODBC Bridge should become unnecessary.
The JDBC-ODBC Bridge offers several advantages over "naked" ODBC.
The ideal is "Pure Java": no native code, no platform-dependent features. But you may need to begin your development effort right away, without waiting for your DBMS to offer a Java-only JDBC driver. Partly-native drivers, such as the JDBC-ODBC Bridge, let you create programs that easily adapt to Pure Java drivers as they become available.
jdbc:odbc:
connection can now have a
charSet
property, to specify a Character Encoding
Scheme other than the client default. For possible values, see
the
JDK 1.1 Internationalizaton specification
on the Java Software Web Site. // Load the JDBC-ODBC bridge driver Class.forName(sun.jdbc.odbc.JdbcOdbcDriver) ; // setup the properties java.util.Properties prop = new java.util.Properties(); prop.put("charSet", "Big5"); prop.put("user", username); prop.put("password", password); // Connect to the database con = DriverManager.getConnection(url, prop);