Listener refused the Connection with the following error: ORA-1251 JAVA ORACLE

Asked

Viewed 928 times

0

Hello,

I’m having an error when I try to connect to an oracle bank. someone I was able to help.

code

private static Connection ObterConexao() {
    Connection conexao = null;
    try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        try {
            conexao = DriverManager.getConnection("jdbc:oracle:thin:@IP:1521/xe", "USUARIO", "SENHA");
        } catch (SQLException ex) {
            Logger.getLogger(conexao.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return conexao;
}

Error

GRAVE: null
java.sql.SQLRecoverableException: Listener refused the connection with the 
following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:774)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.telefonica.DAO.conexao.ObterConexao(conexao.java:25)
at com.telefonica.DAO.conexao.idTiquete(conexao.java:37)
at com.telefonica.CT.Start.upDateSLA(Start.java:33)
at com.telefonica.CT.Start.<init>(Start.java:53)
at com.telefonica.CT.Start$1.run(Start.java:128)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: oracle.net.ns.NetException: Listener refused the connection with 
the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
  • 1

    https://stackoverflow.com/q/10786782/5524514

  • Articuno, I had already looked and did not find the solution, because it seems that they do not use connection via string

1 answer

0


I managed to solve the problem, in case someone has the same problem. Was in the URL

Wrong

conexao = DriverManager.getConnection("jdbc:oracle:thin:@IP:1521/xe", "USUARIO", "SENHA");

Right (MY CONNECTION DIDN’T USE XE BUT THE NAME OF THE SCHEME.

conexao = DriverManager.getConnection("jdbc:oracle:thin:@IP:1521/ESQUEMA, "USUARIO", "SENHA");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.