Oracle 10g 与 Java 的连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5382018/
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 10g connection with Java
提问by ChArAnJiT
what are the drivers which are used to connect with java for Desktop application. i have found many types like tiny and all but was not able to understand. Please help me out
什么是用于与桌面应用程序的 java 连接的驱动程序。我发现了很多类型,比如 tiny 和 all,但无法理解。请帮帮我
回答by Pablo Santa Cruz
To make your life easier, I would recommend just using Oracle's Thin Driver.
为了让您的生活更轻松,我建议您只使用 Oracle 的 Thin Driver。
First, download the driver from Oracle's site:
首先,从Oracle 的站点下载驱动程序:
http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
Then add JAR to your project and connect to database using:
然后将 JAR 添加到您的项目并使用以下命令连接到数据库:
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@//localhost:1521/orcl", "scott", "tiger");
Of course, replace these parameters with the ones corresponding to your DB.
当然,将这些参数替换为与您的数据库对应的参数。
回答by Jigar Joshi
回答by pintu
for oracle 10g the JDBC driver is "ojdbc10_g.jar"
对于 oracle 10g,JDBC 驱动程序是“ojdbc10_g.jar”
it is available on your system inside %ORACLE_HOME\jdbc\lib No need to download.
它在您的系统上可用 %ORACLE_HOME\jdbc\lib 无需下载。
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@//localhost:1521/orcl", "scott", "tiger");
conn.setAutoCommit(false);
回答by FelipeFG
The "thin" driver is a 100% java implementation. The OCI calls the C implementation. There might even be a JDBC to ODBC bridge, allowing you to use your system's ODBC driver. Suggested reading: Oracle Instant Client
“瘦”驱动程序是 100% 的 java 实现。OCI 调用 C 实现。甚至可能有一个 JDBC 到 ODBC 桥,允许您使用系统的 ODBC 驱动程序。推荐阅读:Oracle Instant Client
回答by Brent Worden
The easiest one to deploy is probably the type 4 driver, or the thin driver. I say it is the easiest because it does not rely on any Oracle native libraries or client install to operate. It is readily available from Oracle.
最容易部署的可能是 type 4 驱动程序或瘦驱动程序。我说它是最简单的,因为它不依赖于任何 Oracle 本地库或客户端安装来运行。它很容易从Oracle 获得。