Reputation: 237
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)
Upvotes: 6
Views: 10146
Reputation: 69
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 /
Upvotes: 6
Reputation: 65044
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;
.
Upvotes: 1
Reputation: 7844
Oracle's JDBC thin URI syntax is as follows:
jdbc:oracle:thin:[USER/PASSWORD]@//[HOST][:PORT]/SERVICE
So:
jdbc:oracle:thin:@//winson.net:1522/hcrod"
Note the two slashes added after the @ symbol.
Upvotes: 0
Reputation: 7889
It sounds like the port on the server isn't listening, port 1522.
Can you telnet
the port successfully?
Upvotes: 0