Forum Stats

  • 3,838,654 Users
  • 2,262,389 Discussions
  • 7,900,724 Comments

Discussions

JDeveloper and Oracle connection

664955
664955 Member Posts: 3
edited Oct 14, 2008 10:38AM in JDeveloper and ADF
Recently I have been connecting to a database on another computer through JDeveloper. I just installed Oracle Express 10g on my computer and am having trouble with the connection. After setting up the connection under "Connections" in the JDeveloper navigator, I press test, and it connects with "Success!" I am using a connection Type: Oracle (JDBC), driver: thin, hostname: localhost, port 1521, SID: XE.

But when I run my program, I get this error:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:orcl

My class connects using this code:

public void setDBConnection() throws SQLException{
OracleDataSource ds;
ds = new OracleDataSource();
ds.setURL(jdbcUrl);
mConn = ds.getConnection(userid,password);
}

where jdbcUrl ="jdbc:oracle:thin:localhost:1521:XE";
and of course my userid and password are correct.

I don't understand why it comes back with the SID "orcl"



My listener.ora is this: , where my computer name is STACECASE. I also tried it with LOCALHOST
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\10.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\10.2.0\server)
(PROGRAM = extproc)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = STACECASE)(PORT = 1521))
)
)

DEFAULT_SERVICE_LISTENER = (XE)
Tagged:

Answers

  • Shay Shmeltzer-Oracle
    Shay Shmeltzer-Oracle Director of Product Management for Oracle's Cloud Development Tools Posts: 16,870 Employee
    I'm guessing that there is another part in your application that uses another connection string - try to set a breakpoint on the exception to see where is it coming from.
  • 664955
    664955 Member Posts: 3
    I stepped through the debugger and the error is right here: mConn = ds.getConnection(userid,password);
    in this function:
    public void setDBConnection() throws SQLException{
    OracleDataSource ds;
    ds = new OracleDataSource();
    ds.setURL(jdbcUrl);
    mConn = ds.getConnection(userid,password);
    }

    jdbcUrl = "jdbc:oracle:thin:localhost:1521:XE"

    but the error message says this:
    "error making connection java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    The Connection descriptor used by the client was:
    localhost:1521:orcl"

    I don't see why it would get the "orcl" SID.
  • 664955
    664955 Member Posts: 3
    edited Oct 14, 2008 10:38AM
    OK, I answered my question. I needed the host to be @localhost,

    jdbcUrl ="jdbc:oracle:thin:@localhost:1521:XE"

    instead of

    jdbcUrl ="jdbc:oracle:thin:localhost:1521:XE"

    Edited by: user4932007 on Oct 14, 2008 7:38 AM
This discussion has been closed.