oracle jdbc 驱动版本疯狂
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/756208/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
oracle jdbc driver version madness
提问by Stroboskop
Why the heck does Oracle offer a different(!) version of the JDBC driver, e.g. ojdbc14.jar, for every(!) database version?
The files all have different sizes and thus probably different content.
为什么 Oracle 为每个(!)数据库版本提供不同(!)版本的 JDBC 驱动程序,例如 ojdbc14.jar?
这些文件都有不同的大小,因此可能有不同的内容。
background:
We get a random and seemingly irreproducible error saying "invalid number" when saving data (we guess it's the Timestamp). But it's not any particular statement. Most of the time, it saves just fine. Just once a month a harmless looking statement will fail.
背景:
我们在保存数据时收到一个随机且看似不可复制的错误,提示“无效数字”(我们猜测是时间戳)。但这不是任何特别的声明。大多数情况下,它保存得很好。每月一次,看似无害的声明将失败。
So i had a closer look at Oracle's download site and noticed that none of the filesizes match despite files sharing the same name.
所以我仔细查看了 Oracle 的下载站点,并注意到尽管文件共享相同的名称,但没有一个文件大小匹配。
Our product is run on databases maintained by our clients, i.e. whatever version and patch the clients have running is what it is.
So what driver do we use? The latest (Oracle 11g) - despite the fact that it's usually 9i and10g databases?
我们的产品运行在我们客户维护的数据库上,即客户运行的版本和补丁就是它。
那么我们使用什么驱动程序呢?最新的(Oracle 11g)——尽管它通常是9i 和10g 数据库?
Why don't they just link all versions to the same "one driver suits all" file?
Or are there minute differences leading to effects like our random errors?
他们为什么不将所有版本链接到同一个“一个驱动程序适合所有”文件?
或者是否有细微的差异导致像我们的随机错误这样的影响?
EDIT: i was mistaken about the 9i databases.
编辑:我对 9i 数据库有误解。
回答by Oliver Michels
please see the compatibility matrix at http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#02_02
请参阅http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#02_02 上的兼容性矩阵
Also take in mind that the timestamp datatype is only available since Oracle 10.
还要记住,时间戳数据类型仅从 Oracle 10 开始可用。
回答by Jean de Lavarene
The numbers in ojdbc14.jar, ojdbc5.jar, ojdbc6.jar, ojdbc7.jar and ojdbc8.jar refer to the version of the Java compiler that was used. With every version of Java come new JDBC APIs so these numbers are useful to know what to expect. For example in Java 8, there is a new method executeLargeUpdate
in java.sql.PreparedStatement
. This method will be implemented in ojdbc8.jar but not in ojdbc7.jar. Also if your runtime uses Java 7 then you know you can't use ojdbc8.jar otherwise you'll run into a java.lang.UnsupportedClassVersionError
error. These are the reasons why Oracle includes these numbers in the jar's name. Also note that if you want to know from which Oracle Database release the jar comes from you can run java -jar ojdbc8.jar
. Both the Database and the driver are backward compatible (up to 1 major release) so, even though it's recommended, you don't have to use the same version of the product on both tiers.
ojdbc14.jar、ojdbc5.jar、ojdbc6.jar、ojdbc7.jar 和 ojdbc8.jar 中的数字是指所使用的 Java 编译器的版本。每个版本的 Java 都会带来新的 JDBC API,因此这些数字对于了解预期内容非常有用。例如在Java中8,有一种新的方法executeLargeUpdate
中java.sql.PreparedStatement
。此方法将在 ojdbc8.jar 中实现,但不在 ojdbc7.jar 中。此外,如果您的运行时使用 Java 7,那么您就知道不能使用 ojdbc8.jar,否则会遇到java.lang.UnsupportedClassVersionError
错误。这就是 Oracle 在 jar 名称中包含这些数字的原因。另请注意,如果您想知道 jar 来自哪个 Oracle 数据库版本,您可以运行java -jar ojdbc8.jar
. 数据库和驱动程序都向后兼容(最多 1 个主要版本),因此,即使是推荐的,您也不必在两个层上使用相同版本的产品。
回答by asalamon74
When we upgraded our Oracle database from 8.1.7 to 10.2.0, I was able to use the same Oracle jdbc driver (ojdbc14.jar). So their jdbc driver supports quite a few versions at the same time. Of course it's possible that some of the drivers are buggy, but the plan is to support more versions at the same time.
当我们将 Oracle 数据库从 8.1.7 升级到 10.2.0 时,我能够使用相同的 Oracle jdbc 驱动程序 (ojdbc14.jar)。所以他们的jdbc驱动同时支持好几个版本。当然,有些驱动程序可能有问题,但计划是同时支持更多版本。