我的问题是我尝试连接到远程Oracle数据库。它的版本是9.2.0.6,我使用jdk 1.7和ojdbc14.jar。

这是代码:

Connection connection = null;

    try {

        connection = DriverManager.getConnection("jdbc:oracle:thin:@//10.130.34.3:1522/myDB", "binette","Passer");

    } catch (SQLException e) {

        System.out.println("Connection Failed! Check output console");
        e.printStackTrace();
        return;

    }


我得到了这个错误:

Connection Failed! Check output console
java.sql.SQLException: Exception d'E/S: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153093632)(ERR=12514)(ERROR_STACK=(ERROR=(CODE=12514)(EMFI=4))))
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
    at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3668)
    at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:353)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:371)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:551)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:351)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)


我试图将jdbc jar颂唱到classes12.jar,但这是相同的错误。
我已经在互联网上搜索了,但无法解决问题。

最佳答案

看起来像ORA-12514: TNS:listener does not currently know of service requested in connect descriptor(根据错误代码)。
因此,也许您的服务名称不是myDB?

关于java - 尝试连接到Oracle数据库时出现java.sql.SQLException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27267988/

10-11 15:51