Hello,
I'm having an error when I try to connect to an Oracle database. Someone could 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