Oracle连接的简单问题,在线等待!
下面是ORACLE8i附带的一个JDBC的简单例子,SID等我已改成自己的。
但编译时却说找不到OracleDriver这个东东,该怎么办?
另外Oracle的驱动还有一种thin,到底是什么玩艺??它们之间有何区别?
import java.sql.*;
class A
{
public static void main (String args [])
throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String url = "jdbc:oracle:XCQ:@";
try {
String url1 = System.getProperty("JDBC_URL");
if (url1 != null)
url = url1;
} catch (Exception e) {
// If there is any security exception, ignore it
// and use the default
}
// Connect to the database
Connection conn =
DriverManager.getConnection (url, "Robin", "robin");
// Create a Statement
Statement stmt = conn.createStatement ();
// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select * from TEST_DB1");
// Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));
// Close the RseultSet
rset.close();
// Close the Statement
stmt.close();
// Close the connection
conn.close();
}
}