Could someone please help me on why I received the following error while trying to connect to Oracle db from java....
The connection call is:
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@winson.net:1522/hcrod",
"manager", "passing");
I receive the following error:
java.sql.SQLException: 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.DatabaseError.throwSqlException(DatabaseError.java:113)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:389)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:454)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:802)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at test_sample.main(test_sample.java:15)
getConnection(url, username,password); } catch (ClassNotFoundException e) { System. out. println("NO JDBC driver"); return null; } catch(IOException e) { System.
SQLException MethodsGets the JDBC driver's error message for an error, handled by the driver or gets the Oracle error number and message for a database error. Gets the XOPEN SQLstate string. For a JDBC driver error, no useful information is returned from this method.
JDBC connection errors. Connection errors are typically caused by incorrect or invalid connection string parameters, such as an invalid host name or database name. Verify that you are using correct and valid connection string parameters for the Gate.
in a similar case for me worked a slightly other connect string:
jdbc:oracle:thin:@winson.net:1522:hcrod
really without the //
and with : instead of /
I've seen this error come up a few times when I've started the TNS listener after I started the database. When the database starts up it registers itself with the listener if the listener is running, but if the listener isn't running it can't do this.
It's possible to manually persuade the database to register itself with the listener. To do this, connect to the database as SYS
and run the SQL statement ALTER SYSTEM REGISTER;
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With