我想使用4型驱动程序。我正在使用eclipse,oracle 10g。我下载了ojdbc14.jar并将其放在javaBuildPath中。
这是我的代码。它显示我错误
import java.sql.*;
import java.util.Properties;
public class Demo
{
public static void main(String args[]) throws SQLException, ClassNotFoundException
{
Class.forName("oracle.jdbc.pool.OracleDataSource");
String url = "jdbc:oracle:thin:@localhost:8080:";
Connection conn = DriverManager.getConnection(url,"system","1234");
String sql ="select sysdate as current_day from dual";
PreparedStatement preStatement = conn.prepareStatement(sql);
ResultSet result = preStatement.executeQuery();
while(result.next())
{
System.out.println("Date" + result.getString("current_day"));
}
}
}
答案 0 :(得分:0)
我以这种方式使用瘦客户端:
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@999.999.999.999:8888:INSTANCE_NAME",
"user", "password");
conn.close();