0

我想使用类型 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"));
            }      
        }
    }
4

1 回答 1

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();
于 2013-06-26T15:37:56.747 回答