This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes Error facing while trying to connect Oracle XE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error facing while trying to connect Oracle XE" Watch "Error facing while trying to connect Oracle XE" New topic
Author

Error facing while trying to connect Oracle XE

Rudra Nath
Greenhorn

Joined: May 12, 2012
Posts: 9
I installed Oracle XE in my PC and tried to connect to Oracle using JDBC.
I am getting error:"listener does not currently know of service requested in connect descriptor", while trying to connect to Oracle XE using JDBC.
Please help.
Please find below code snippet, and TNSNAMES.ORA for the database



error:
INFO: Jk running ID=0 time=0/64 config=null
29 Apr, 2012 1:00:23 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 8264 ms
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
The Connection descriptor used by the client was:
Rudre-PC:1521

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:111)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:260)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:386)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
413)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:164)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
n.java:34)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:752)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

and you can connect using these values from the oracle client (SQLPLUS or something better if they now supply that)?

I did a quick search out there and the actions a website i trust suggested were

  • Wait a moment and try to connect a second time.
  • Check which services are currently known by the listener by executing: lsnrctl services
  • If an easy connect naming connect identifier was used, check that the service name specified is a service known by the listener.
  • Check for an event in the listener.log file.
  • Wendy Gibbons
    Bartender

    Joined: Oct 21, 2008
    Posts: 1107

    And welcome to JavaRanch Rudra Nath
    chris webster
    Bartender

    Joined: Mar 01, 2009
    Posts: 1784
        
      16

    Oracle XE only gives you one database, and its name is "XE".

    I think your connection string should look like this:

    If you are working on a local machine, you could also try changing the machine name in your JDBC string and your TNSNAMES to be "localhost" (or the default TCP loopback address 127.0.0.1).




    No more Blub for me, thank you, Vicar.
    Rudra Nath
    Greenhorn

    Joined: May 12, 2012
    Posts: 9
    Many Thanks Chris.
    Your solution helped me!!!
    Thanks again!!!
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Error facing while trying to connect Oracle XE