通过ODBC连接使用Hibernate [英] Using Hibernate via an ODBC connection

查看:191
本文介绍了通过ODBC连接使用Hibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过ODBC连接(而不是我的决定)使用Hibernate,并想知道这样做的注意事项(如果甚至可能的话)。我做了一些研究,并且有些困惑,希望有人能澄清一些观点。好像我需要使用JDBC-ODBC桥接器?

Type_1_Driver _-_ JDBC_ ODBC_bridgerel =nofollow> Wiki - JDBC / ODBC Bridge


  1. 填充不同的JDBC类型(1-4)。从我所能理解的情况来看,驱动程序的具体实现细节随着类型版本而增加?即。类型1 ODBC驱动程序不能支持类型4驱动程序可以使用的相同功能?它看起来像一个ODBC驱动程序不能超过1,而JDBC驱动程序(可)达到4?

  2. 如果目标数据库有自己的ODBC驱动程序,需要什么样的支持才能工作?我是否应该查看文档以查看是否存在级别1,级别N等等?
  3. 类似于上述问题,我如何确保LOB字段打算工作/休息?是否需要在ODBC驱动程序中实现级别或某些SQL函数?

不幸的是,我在理解hibernate所需的东西方面存在一些断层,因为我找不到任何文档至于它需要什么。一个解释和/或文档将是伟大的。

解决方案


ODBC doesn没有像java那样的'驱动程序类型'。主要区别(以及为什么Java有驱动程序类型)是因为某些驱动程序需要本地扩展,这些扩展不能跨不同的操作系统/体系结构移植。

例如,JDBC驱动程序类型1 ,有纯粹的本地绑定。因此,如果你有使用这个驱动程序在Windows上运行的东西,你不能把你的应用程序和部署到Linux,因为存在二进制不兼容性。



JDBC驱动程序类型4位于规模的另一侧,它纯粹用java编写,所以它可以在任何可以运行JVM的平台上运行,而无需转换调用的服务(类型3驱动程序就是这种情况) 。

因此,类型1是纯原生类型,类型4是纯java,中间有不同的阴影。



2)您需要检查数据库供应商驱动程序。你可以说你正在使用哪个数据库?



3) LOB字段应该工作,但它也取决于驱动程序,可能会有一些奇怪的限制,比如驱动程序无法处理大于4k的Lob字段)。

我的专业建议是,原因如下:


  • 取自oracle站点: JDBC-ODBC Bridge驱动程序建议用于原型开发工作,对于不存在其他基于JDBC技术的驱动程序的情况
  • 来自维基百科的
  • 与其他驱动程序类型相比,它很慢

  • 在其他数据库供应商网站上,您会发现类似的评论,因为在过去的12年(或更多)年中,JDBC驱动程序已发展为

  • 您正在编写java,而不是VB.Net



请不要害怕显示那个人他/她错了(当然是一种很好的方式)。

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.

解决方案

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 profesional suggestion is that you punch the person who decided this on the nuts 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

And please, don't be afraid of showing that person that he/she is wrong (in a nice way of course).

这篇关于通过ODBC连接使用Hibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆