无法获得oracle数据库连接

时间:2017-03-11 16:43:37

标签: jdbc oracle11g websphere-8 ojdbc ibm-jdk

1.JAVA_HOME设置为IBM JAVA SDK。 2.无法获得oracle数据库连接。尝试在将Oracle java设置为JAVA_HOME的计算机上运行相同的操作 3.在AppServer / lib下放置ojdbc14.jar。

   try {

  connection = DriverManager.getConnection(
      "jdbc:oracle:thin:@10.10.24.40:1521/konydb", "installer", "kony1234");

} catch (SQLException e) {

  System.out.println("Connection Failed! Check output console");
  e.printStackTrace();
  return;

}

if (connection != null) {
  System.out.println("You made it, take control your database now!");
} else {
  System.out.println("Failed to make connection!");
}

我需要做什么设置。下面是错误

  

Oracle JDBC驱动程序已注册!连接失败!检查输出控制台   java.sql.SQLRecoverableException:IO错误:网络适配器可以   没有建立连接           在oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:517)           在oracle.jdbc.driver.PhysicalConnection。(PhysicalConnection.java:557)           在oracle.jdbc.driver.T4CConnection。(T4CConnection.java:233)           at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:29)           at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:556)           在java.sql.DriverManager.getConnection(DriverManager.java:583)           在java.sql.DriverManager.getConnection(DriverManager.java:227)           在OracleJDBCExample.main(OracleJDBCExample.java:29)引起:oracle.net.ns.NetException:网络适配器无法   建立联系           在oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:389)           at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:431)           at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:882)           at oracle.net.ns.NSProtocol.connect(NSProtocol.java:267)           at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1625)           在oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:365)           ... 7更多引起:java.net.SocketTimeoutException:连接超时           at java.net.PlainSocketImpl.socketConnect(Native Method)           在java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:370)           at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:231)           在java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:213)           在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:404)           在java.net.Socket.connect(Socket.java:643)           at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:147)           在oracle.net.nt.ConnOption.connect(ConnOption.java:130)           在oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:367)

谢谢, 库苏马

1 个答案:

答案 0 :(得分:1)

这里有几件事需要检查:

  • 您可以在10.10.24.40上连接到1521端口吗? (尝试telnet,netcat或类似的东西)
  • 听众是否接受连接?即sqlplus用户名/pw@10.10.24.40:1521 / konydb工作吗?
  • 是SID正确(konydb)?
  • 您是否尝试使用服务名称而不是SID进行连接: jdbc:oracle:thin:@//10.10.24.40:1521/<service name>

另见 Java JDBC - How to connect to Oracle using Service Name instead of SID