[英]java.sql.SQLException: IO Exception : The Network adapter could not establish the connection?
[英]Getting “java.sql.SQLException: Io exception: The Network Adapter could not establish the connection”
下面是我的代碼。 我想從Oracle連接到Employee表。
public static void main(String[] args) {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection connection = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
Statement statement = connection.createStatement();
ResultSet resultset = statement.executeQuery("select 'Connected' from dual");
resultset.next();
String s = resultset.getString(1);
System.out.println(s);
statement.close();
connection.close();
} catch (Exception e) {
System.out.println("The exception raised is:" + e);
}
}
我總是收到錯誤消息,因為“引發的異常是:java.sql.SQLException:Io異常:網絡適配器無法建立連接”
我嘗試關閉防火牆,但是沒有運氣。 有人可以幫我解決問題。
您是否嘗試過遠程登錄該數據庫? 就像是...
Telnet localhost 1521
僅檢查該端口是否有進程列表。
它可以是三個瘦:
好的,當我的團隊位於黑匣子服務器中,該URL帶有用於連接數據庫的URL時,我們不知道發生了什么錯誤,因此我們創建了可以進行此測試的UDL文件 。 查看本教程進行連接測試。使用該教程,您可以測試它們中的三個,並查看是否與數據庫建立了真正的連接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.