public class Jdbc1 {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.OracleDriver");
//System.out.println("OK");
String url = "jdbc:oracle:thin:@192.168.1.102:1521:orcl";
String username = "system";
String password = "orcl";
Connection conn = DriverManager.getConnection(url, username, password);
System.out.println(conn.getClass());
}
}
Exception in thread "main" java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:439)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at cn.csq.jdbc.Jdbc1.main(Jdbc1.java:15)
一直提示这个异常,网上找了好多方法都不行啊啊,有大神知道哪里错了吗?我在sqlplus能连接数据库,在PLSQL Developer也能进去,求指导,感激不尽
产品经理不是经理
相关分类