谁知道这到底是怎么回事,java连接oracle数据库,在eclipse下已经引入classes12.jar包了,还是不行,真么郁闷
package student;import java.lang.*;
import java.sql.*;
public class JDBCoracle{
public static final String driverClassName = "oracle.jdbc.driver.OracleDriver";
public static final String url = "jdbc:oracle:thin:@localhost:1521:orcl";
public static final String password = "472312";
public static final String user= "sys as sysdba";
public static void main(String[] args) throws Exception{
Connection conn = null;
Class.forName(driverClassName);
conn = DriverManager.getConnection(url, user, password);
System.out.println(conn);
conn.close();
}
}
错误异常:
Exception in thread "main" java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:345)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:428)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:515)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:345)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at student.JDBCoracle.main(JDBCoracle.java:14)