Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 468 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
JDeveloper and Oracle connection

664955
Member Posts: 3
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)
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 Director of Product Management for Oracle's Cloud Development Tools Posts: 16,870 EmployeeI'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.
-
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. -
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.