[英]Not able to connect to Oracle DB getting error as java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
Here is the code which i am trying- ORACLE driver is loaded successfully but getting in get connection that statement- 这是我正在尝试的代码-ORACLE驱动程序已成功加载但进入该语句的连接-
public class OracelConn {
public static void main(String[] args) throws Exception {
try {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("Please include Classpath Where your ORACLE Driver is located");
e.printStackTrace();
return;
}
System.out.println("ORACLE driver is loaded successfully");
Connectioncon=DriverManager.getConnection( "jdbc:oracle:thin:or0132p.exg.com:1521:OP0132.exg.com", "wsteam", "wsteam");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select TC_ORDER_ID from orders where tc_order_id='0296906379'");
while (rs.next())
System.out.println(rs.getString("TC_ORDER_ID"));
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
There seems to be an issue with your URL
format. 您的
URL
格式似乎有问题。 Below are supported formats: 以下是受支持的格式:
If you have an SID, use this (older) format: 如果您有SID,请使用以下(较旧的)格式:
jdbc:oracle:thin:@[HOST][:PORT]:SID
If you have an Oracle service name, use this (newer) format: 如果您具有Oracle服务名称,请使用以下(较新的)格式:
jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.