if the file is in the path of "C:\JdbcDriver",then you should add a line or append in "Autoexec.bat" file as the following:CLASSPATH=%CLASSPATH%;C:\JdbcDriver\class12.zip; you should assure that the class12.zip exists
On Win95/Win98/NT: - Add [ORACLE_HOME]\jdbc\lib\classes111.zip and [ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH. (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.) - Add [ORACLE_HOME]\jdbc\lib to your PATH.或者将classes12.zip 改名为 classes12.jar,nls_charset12.zip 改为nls_charset12.jar ,然后 copy 到 [java_home]\jre\lib\ext 下面测试代码:/* * This sample shows how to list all the names from the EMP table * * It uses the JDBC THIN driver. See the same program in the * oci8 samples directory to see how to use the other drivers. */// You need to import the java.sql package to use JDBC import java.sql.*;class Employee { public static void main (String args []) throws SQLException { // Load the Oracle JDBC driver DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // Connect to the database // You must put a database name after the @ sign in the connection URL. // You can use either the fully specified SQL*net syntax or a short cut // syntax as <host>:<port>:<sid>. The example uses the short cut syntax. Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@dlsun511:1721:dbms733", "scott", "tiger"); // Create a Statement Statement stmt = conn.createStatement (); // Select the ENAME column from the EMP table ResultSet rset = stmt.executeQuery ("select ENAME from EMP"); // Iterate through the result and print the employee names while (rset.next ()) System.out.println (rset.getString (1)); } }
you should assure that the class12.zip exists
DriverManager.registerDriver(new oracle.jdbc.driver.oracleDriver());
第一步:打开菜单上的tools菜单条,选中Enterprise Setup项,打开后再选择DataBase Drivers标签,选择Add,然后建立你自己起名的drivers lib,其实就是
用一个名字表示你的class12.zip的位置,非常简单,建立后你可以在DataBase Drivers标签下看见一个与你驱动程序库名相同名字的config文件。
第二步:在你的工程里,记住是在你的工作的工程里加入这个第一步起了别名的类库,具体是在你的工程上单击右键,选中properties项,然后选中PATH标签,然后在这个标签下在选种Required Libraries标签,然后选择ADD加入第一步起了别名的类库就可以了
- Add [ORACLE_HOME]\jdbc\lib\classes111.zip and
[ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
(Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
- Add [ORACLE_HOME]\jdbc\lib to your PATH.或者将classes12.zip 改名为 classes12.jar,nls_charset12.zip 改为nls_charset12.jar ,然后 copy 到 [java_home]\jre\lib\ext 下面测试代码:/*
* This sample shows how to list all the names from the EMP table
*
* It uses the JDBC THIN driver. See the same program in the
* oci8 samples directory to see how to use the other drivers.
*/// You need to import the java.sql package to use JDBC
import java.sql.*;class Employee
{
public static void main (String args [])
throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // Connect to the database
// You must put a database name after the @ sign in the connection URL.
// You can use either the fully specified SQL*net syntax or a short cut
// syntax as <host>:<port>:<sid>. The example uses the short cut syntax.
Connection conn =
DriverManager.getConnection ("jdbc:oracle:thin:@dlsun511:1721:dbms733",
"scott", "tiger"); // Create a Statement
Statement stmt = conn.createStatement (); // Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select ENAME from EMP"); // Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));
}
}