如何使用IntelliJ IDEA将虚拟机窗口7中的ORACLE DB连接起来。我在库中有jdbc7.jar,我尝试这种方式。告诉我这个错误:
java.sql.SQLRecoverableException: Error input-output: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:711)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:445)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:464)
... 12 more
Caused by: java.net.SocketException: Network is unreachable: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
... 17 more
和
Class.forName("oracle.jdbc.driver.OracleDriver");
String serverName = "000.000.000.000";
String portNumber = "1521";
String sid = "abcd";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "user";
String password = "pass";
Connection conn = DriverManager.getConnection(url, username, password);