up
JDBC OCI驱动是将JDBC调用直接转换为oracle net调用
JDBC OCI驱动是将JDBC调用直接转换为oracle net调用
解决方案 »
- ORACLE 11g2.0.3安装问题
- Oracle语句遇到难题,急~~~在线等~~~~~~
- 【请教】前辈们,关于引用游标的一个小问题
- Oracle中日文和韩文都显示乱码,但为什么查找时能匹配日文,而不能匹配韩文?
- 如何判断表1的a字段的值存在于表2的b字段的值内??
- 请问pl/sql中在where in()子句里怎么使用字符串变量来传递查询条件?
- 一个比较弱智的问题望大家帮个忙
- Oracle数据导入问题
- 高手:请我个例子,编写有输入参数的插入数据到CLOB字段的存储过程(100分)急急急!!
- 如何学好Oracle,成为一个合格的DBA,应该怎么做?请大家帮帮我
- 请教一个xmltype数据存储的问题
- 表中有一个字段是Blob型的,如何将文件插入到此字段里面呢?!9i数据库... 谢谢!
=================================
在ORACLE8i中有三种类型的JDBC驱动,他们都使用相同的 syntax, APIs, and Oracle extensions,以使JAVA代码在robust clients、Web-based Java applets, and Java stored procedures之间保持轻便灵活:三种类型如下:
1.JDBC OCI: 此驱动类似于传统的ODBC 驱动。因为它需要Oracle Call Interface and Net8,所以它需要在运行使用此驱动的JAVA程序的机器上安装客户端软件
2.JDBC Thin: 这种驱动一般用在运行在WEB浏览器中的JAVA程序。它不是通过OCI or Net8,而是通过Java sockets进行通信 ,因此不需要在使用JDBC Thin的客户端机器上安装客户端软件。
3.JDBC KPRB: 这种驱动由直接存储在数据库中的JAVA程序使用,如Java Stored Procedures 、triggers、Database JSP's。It uses the default/ current database session and thus requires no additional database username, password or URL.
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();
}
}