java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:list


package DisplayAuthors;
import  java.sql.*;
public class DisplayAuthors 
{
private static final  String  DATABASE_URL="jdbc:oracle:thin:@localhost:1521:orcl";                             //here  is  5  rows
public static void main(String[] args) {
Connection  connection=null;
Statement  statement=null;
ResultSet  resultset=null;
try
{
connection=DriverManager.getConnection(DATABASE_URL,"scott","123456");
statement=connection.createStatement();
resultset=statement.executeQuery("select  *  from  emp");
ResultSetMetaData  metadata=resultset.getMetaData();
int  numberofcolumns=metadata.getColumnCount();
for(int  count=1;count<numberofcolumns;count++)
{
System.out.printf("%-8s\t",metadata.getColumnName(count));
}
System.out.println();
while(resultset.next())
{
for(int count=1;count<numberofcolumns;count++)
{
System.out.printf("%-8s\t", resultset.getObject(count));
}
System.out.println();
}
}
catch(SQLException  sqlexception)
{
sqlexception.printStackTrace();
}
finally
{
try
{
resultset.close();
statement.close();
connection.close();
}
catch(Exception  exception)
{
exception.printStackTrace();
}
}


}


}

代碼如上,出現這個錯誤的原因有很多,如果是代碼上的原因,就應該檢查一下第五行代碼那里"dbc:oracle:thin:@localhost:1521:orcl"中的"orcl"是不是創建數據庫時的那個SID,如果不是就會出錯。注意此處不是連接名,而是SID。

如果這里是正確的,那么就可能是監聽程序的錯誤。這種錯誤可以自行搜索一下,網上的關於題目上的錯誤討論的最多的就是這種原因。可以自行搜索解決方案來解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor 使用Oracle SQL Developer連接數據庫中遇到Listener refused the connection with the following error:ORA-12505, TNS:listener does not currently know of SID given in connect descriptor Connection to Oracle failed. [66000][12505] Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor . 66000][12505] Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor oracle.n et.ns.NetException: Listener refuse Oracle SQL developer連接數據庫報錯:ORA-12505 listener refused the connection with the following error…… Oracle中Error while performing database login with the XXXdriver; Listener refused the connection with the following error; ORA-12505,TNS:listener does not currently know of SID given inconnect descrip java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver 與 java.sql.SQLException: Listener refused the connection with the following error: 及”java連接oracle數據庫“ java.sql.SQLException: Io 異常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)(ERR=12505)(ERR Oracle連接出現error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM