gpt4 book ai didi

java - 无法连接到 Oracle DB,出现错误 java.sql.SQLException : Io exception: The Network Adapter could not establish the connection

转载 作者:行者123 更新时间:2023-12-02 10:31:48 26 4
gpt4 key购买 nike

这是我正在尝试的代码-ORACLE驱动程序已成功加载但进入get连接该语句-

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);
}
}
}

最佳答案

您的 URL 格式似乎存在问题。以下是支持的格式:

如果您有 SID,请使用此(较旧的)格式:

jdbc:oracle:thin:@[HOST][:PORT]:SID

如果您有 Oracle 服务名称,请使用此(较新的)格式:

jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE

来源:orafaq

关于java - 无法连接到 Oracle DB,出现错误 java.sql.SQLException : Io exception: The Network Adapter could not establish the connection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53580341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com