【问题标题】:ora 12505 Error listener refused to connectora 12505 错误侦听器拒绝连接
【发布时间】:2012-10-12 17:18:17
【问题描述】:
import java.util.*;
import java.io.*;
import java.sql.*;
public class Stud
{
    public static void main(String args[])
    {
        try
        {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            System.out.println("Driver Registered");
            Connection connection =DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","bh","1234");
            System.out.println("Connection created");
            PreparedStatement ps=connection.prepareStatement("insert into Student(StudName,dob,math,phy,chem,agg) values(?,?,?,?,?,?)");
            System.out.println("prepare stmt ");
            ps.setString(1,"name");

            ps.setString(2,"dob");
            ps.setInt(3,96);
            ps.setInt(4,96);
            ps.setInt(5,94);
            ps.setDouble(6,96);
            int a=ps.executeUpdate();
            ps.close();
            connection.close();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

错误

java.sql.sql exception listner refused to connect with the following error
  ora 12505 the listner currently does not know of sid in give connectoin descriptor
  local host 1521

我使用的是 oracle 10 g,并且在我的类路径中设置了 ojdbc14.jar。 我正在使用 Java 7,我的 tnsname.ora 也包含 (PORT = 1521)) 所以我无法理解给定的错误。

【问题讨论】:

  • ora 12505 the listner currently does not know of sid in give connectoin descriptor 请尽可能复制/粘贴异常输出。这有 2 个拼写错误(listner -> listener,connectoin -> connection)和一个拼写可疑的单词(give -> given)。
  • 您确定在您的本地计算机上运行 Oracle XE 吗?或者再想一想,既然你没有提到运行 Express 版,你确定你要连接的数据库的名称是 XE 吗?

标签: java oracle jdbc oracle10g odbc


【解决方案1】:

您的数据库 URL 错误。它应该是: jdbc:oracle:thin:@localhost:1521/XE

【讨论】:

    【解决方案2】:

    oracle documentation,您的连接字符串应采用以下格式:

    jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename
    

    【讨论】:

      猜你喜欢
      • 2017-08-07
      • 2022-01-02
      • 2023-03-12
      • 2012-08-03
      • 1970-01-01
      • 2018-07-16
      • 1970-01-01
      • 2014-11-21
      • 1970-01-01
      相关资源
      最近更新 更多