简体   繁体   中英

Sun JDBC ODBC Driver or MSSQL JDBC Driver

we have 2 approaches to connecting to our MSSQL databases, the one being the Sun JDBC ODBC bridge and the other being the MSSQL JDBC Driver.

We're doing some reorganization and want a uniform approach to database connectivty.

Which driver should we use? (I'm leaving the question at a very broad level on purpose, I'd like to hear what peoples opinions are)

Sun's bridge driver shouldn't be used for anything other than prototyping and quick development.

You should always use a type IV JDBC driver if one's available. There are two that I know of for SQL Server: Microsoft's version and jTDS .

Even Sun/Oracle says so. This is from their docs :

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).

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.

Use the MSSQL Type 4 JDBC driver provide by Microsoft or the jTDS driver . At the time of writing this, the MSSQL JDBC driver offered by Microsoft is at version 3.0 although version 4 is available as a preview release.

Avoid the Sun JDBC ODBC driver, for it really is a bridge to the ODBC driver installed in the machine. Atleast one question has been asked on StackOverflow on why Type 4 drivers ought to be used as opposed to Type 1 (ODBC bridges) or Type 2 (JNI-based) drivers.

To add to the answers posted in that question, Type 1 (ODBC driver bridges) are to be avoided unless you cannot find a JDBC driver from the vendor. After all, it does not make any business sense to have dependencies on both the ODBC driver offered by the vendor, as well as the Sun JDBC-ODBC driver; any bug encountered in production could be in either. Therefore, if you are making this decision for a line-of-business application, you ought to be using a well-tested third-party JDBC driver (like jTDS or DataDirect ) or the vendor provided driver (unless your experience suggests that the driver is poorly written or that the vendor is incapable of resolving issues or providing workarounds in a sufficient timespan).

There is also the OpenLink Multi-tier JDBC Driver for SQL Server ...

This driver has its place - where additional security and configurability is required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM