我应该使用哪种 JDBC 驱动程序类型来访问 Oracle 数据库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4864029/
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
Which JDBC driver type should I use for accessing an Oracle Database?
提问by Maximilian
We're running a J2EE Application inside a Tomcat WebServer on AIX.
我们在 AIX 上的 Tomcat WebServer 中运行 J2EE 应用程序。
We need to access a few Views and Stored Procedures of an Oracle Database. This oracle datebase is not the one our application is based on, but an external system we have to communicate with.
我们需要访问 Oracle 数据库的一些视图和存储过程。这个 oracle 数据库不是我们的应用程序所基于的数据库,而是一个我们必须与之通信的外部系统。
As far as I can tell from now, we are going to get around a 1000 SELECTs per minute on high load and a few stored procedure calls per hour, if any.
据我现在所知,我们将在高负载下每分钟获得大约 1000 次 SELECT,每小时将获得一些存储过程调用(如果有的话)。
Which JDBC driver type would be the best to use in this situation?
在这种情况下,哪种 JDBC 驱动程序类型最适合使用?
As far as I have gathered type 4 seems to be the way to go, but I haven't been able to find a definite statement about this by Oracle or some other reliable source.
就我收集的类型 4 而言,似乎是要走的路,但我无法找到 Oracle 或其他一些可靠来源对此的明确声明。
回答by a_horse_with_no_name
The Type 4 ("thin") driver is the recommended driver by Oracle.
Type 4(“瘦”)驱动程序是 Oracle 推荐的驱动程序。
The only reason to use the OCI ("thick") driver is when you need the advanced features of a RAC such as transparent application failover (TAF). For everything else the thin driver is recommended.
使用 OCI(“厚”)驱动程序的唯一原因是您需要 RAC 的高级功能,例如透明应用程序故障转移 (TAF)。对于其他一切,建议使用瘦驱动程序。
See the JDBC Developer's Guide for details:
http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/overvw.htm#BABCHIGI
有关详细信息,请参阅 JDBC 开发人员指南:http:
//download.oracle.com/docs/cd/B28359_01/java.111/b31224/overvw.htm#BABCHIGI
The most important sentence is probably:
最重要的一句话大概是:
In general, unless you need OCI-specific features, such as support for non-TCP/IP networks, use the JDBC Thin driver.
通常,除非您需要 OCI 特定的功能,例如支持非 TCP/IP 网络,否则请使用 JDBC Thin 驱动程序。
回答by Sebastian ?askawiec
From my experience I'd suggest using Thin driver. However there are 3 situations in which I'd advice OCI:
根据我的经验,我建议使用 Thin 驱动程序。但是,在 3 种情况下,我会建议 OCI:
- DB and JVM running your program is on the same host. In such case OCI will omit TCP/IP layer and communication might be faster
- You need only Oracle SID to connect to DB, since full client is used. You don't need full DB URL. This might be useful in configuration in dev/test/prod environment.
- You are calling Stored Procedures very (I mean it!) frequently.
- 运行您的程序的 DB 和 JVM 位于同一主机上。在这种情况下,OCI 将省略 TCP/IP 层,通信可能会更快
- 您只需要 Oracle SID 即可连接到数据库,因为使用了完整的客户端。您不需要完整的数据库 URL。这在 dev/test/prod 环境中的配置中可能很有用。
- 您经常(我是认真的!)调用存储过程。
回答by Aravind Yarram
Type 4 seems to be the way to go but you can decide yourself by going through the pros/cons listed here.