怎样安装oci客户端?
在应用开发的时候,通常是用前面两种方式,下面是数据库url的写法:
jdbc:oracle:thin:@server ip: service
jdbc:oracle:oci:@service
看来oci的还更加简洁,ip可以省掉不写了,这是因为oci驱动通过客户端的native java methods来条用c library方式来访问数据库服务器,使用到了客户端的net manager里的数据库服务配置。
因为oci方式最终与数据库服务器通信交互是用的c library库,理论上性能优于thin方式,据说主要是体现在blob字段的存取上。
开发oracle经常用到的 pl sql d...全部
在应用开发的时候,通常是用前面两种方式,下面是数据库url的写法:
jdbc:oracle:thin:@server ip: service
jdbc:oracle:oci:@service
看来oci的还更加简洁,ip可以省掉不写了,这是因为oci驱动通过客户端的native java methods来条用c library方式来访问数据库服务器,使用到了客户端的net manager里的数据库服务配置。
因为oci方式最终与数据库服务器通信交互是用的c library库,理论上性能优于thin方式,据说主要是体现在blob字段的存取上。
开发oracle经常用到的 pl sql dev使用的估计是oci方式,需要安装客户端,但也可以不安装,但是要抽出其中的oci相关的dll即jar包、注册环境变量、配置侦听文件等,详细步骤可参考这个链接http://blog。
csdn。net/shenyc/archive/2009/10/22/4713991。aspx。
oracle在10g之后提供了精简客户端,安装的过程应该包括上面的那些工作。
How does one connect with the JDBC OCI Driver?
One must have Net8 (SQL*Net) installed and working before attempting to use one of the OCI drivers。
Code: [Copy to clipboard]
import java。sql。*;
class dbAccess {
public static void main (String args []) throws SQLException
{
try {
Class。
forName ("oracle。jdbc。driver。OracleDriver");
} catch (ClassNotFoundException e) {
e。printStackTrace();
}
Connection conn = DriverManager。
getConnection
("jdbc:oracle:oci8:@ORA1", "scott", "tiger");
// or oci9 @Service, userid, password
Statement stmt = conn。
createStatement();
ResultSet rset = stmt。executeQuery (
"select BANNER from SYS。V_$VERSION"
);
while (rset。
next())
System。out。println (rset。getString
(1)); // Print col 1
stmt。close();
}
}
How does one connect with the JDBC KPRB Driver?
One can obtain a handle to the default or current connection (KPRB driver) by calling the OracleDriver。
defaultConenction() method。 Please note that you do not need to specify a database URL, username or password as you are already connected to a database session。
Remember not to close the default connection。 Closing the default connection might throw an exception in future releases of Oracle。
import java。sql。*;
Code: [Copy to clipboard]
class dbAccess {
public static void main (String args []) throws SQLException
{
Connection conn = (new
oracle。
jdbc。driver。OracleDriver())。defaultConnection();
Statement stmt = conn。createStatement();
ResultSet rset = stmt。
executeQuery (
"select BANNER from SYS。V_$VERSION"
);
while (rset。next())
System。out。println (rset。
getString
(1)); // Print col 1
stmt。close();
}
}。收起