Ryan
Ryan

Reputation: 3619

Using Hibernate via an ODBC connection

I need to use Hibernate over an ODBC connection (not my decision) and would like to know the caveats of doing so (if it is even possible?). I have done some research and am slightly confused, hoping someone can clarify some points. It seems as if I'll need to use a JDBC-ODBC bridge?

Wiki - JDBC/ODBC Bridge

  1. This page is filled with different JDBC "types" (1-4). From what I can understand, the implementation specific details of the driver increase with the type version? ie. a type 1 ODBC driver can not support the same functions that a type 4 driver can? It seems like an ODBC driver can not go past 1, whereas a JDBC driver (can) get to 4?

  2. If the destination database has their own ODBC driver, what level of support is required to work? Should I look through documentation to see if level 1, level N, etc. calls exist?

  3. Similar to the above question, how can I ensure that LOB fields are going to work / break? Does a level or certain SQL functions need to be implemented in the ODBC driver?

Unfortunately I am at a bit of a disconnect in understanding what is required from hibernate, as I can find no documentation as to what it needs. An explanation and/or documentation would be great.

Upvotes: 1

Views: 4216

Answers (1)

Augusto
Augusto

Reputation: 29977

1) ODBC doesn't have 'driver types' as java does. The main difference (and why Java has driver types) is that some drivers require native extensions which are not portable across different OSs/Architectures.

For example a JDBC driver type 1, has pure native bindings. So if you you have something running on Windows using this driver, you can't take you app and deploy it to linux as there is a binary incompatibility.

A JDBC Driver type 4 is on the other side of the scale, and it's purely written in java, so it can run on any platform that can run a JVM, without the need of a service that translates calls (which is the case with Type 3 drivers).

So Type 1 is pure native, Type 4 is pure java, with different shades in the middle.

2) You need to check the DB vendor driver. Can you say which DB you're using?

3) LOB fields "should" work, but it depends on the driver too, it might have some odd limitations such as "the driver cannot handle Lob fields larger than 4k).

My suggestion is to question the decision to use ODBC because of the following reasons:

  • Taken from the oracle site: The JDBC-ODBC Bridge driver is recommended for use in prototyping efforts and for cases where no other JDBC technology-based driver exists
  • from Wikipedia: Compared to other driver types it's slow
  • And you'll find similar comments on the other database-vendor websites, as the JDBC drivers have evolved A LOT in the last 12 (or more) years.
  • You are writing java, not VB.Net

Upvotes: 3

Related Questions