wood burning stoves 2.0*
The moose likes JDBC and the fly likes Oracle10g: java.sql.SQLException: Invalid Oracle URL specified Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle10g: java.sql.SQLException: Invalid Oracle URL specified" Watch "Oracle10g: java.sql.SQLException: Invalid Oracle URL specified" New topic
Author

Oracle10g: java.sql.SQLException: Invalid Oracle URL specified

Deepak Kumar
Ranch Hand

Joined: Nov 05, 2007
Posts: 62
Hi All,

I am using the below code but I am unable to connect to the database. Its throwing an error "Invalid Oracle URL specified"

DB: oracle 10g
OS: Windows Vista
jar : ojdbc14.jar

Below is the code, please help me




and below is the error I get



Is there anything I am missing ??? Please help me out.

the contents of my listener.ora file is


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 = Deepak-PC)(PORT = 1521))
)
)

DEFAULT_SERVICE_LISTENER = (XE)



Thanks a lot,

Deepak
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Deepak,
Are you able to connect to the "XE" database SID from the command line? This will rule out Java and let you focus on the database configuration part.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Deepak Kumar
Ranch Hand

Joined: Nov 05, 2007
Posts: 62
Jeanne,

yeah, I am able to connect to DB from cmd line successfully

Ed Ward
Ranch Hand

Joined: Jan 30, 2006
Posts: 147
Deepak,

I don't know about the URL syntax or if this is helpful, but where is the username password?
The OracleDataSource() API states this for setUrl(String):
Set the URL from which connections have to be obtained. If URL is set all other properties like databasename, servername, portNumber, network protocol, tnsentry, and driver Type will be ignored.

The API also states
A JDBC driver that is accessed via the DataSource API does not automatically register itself with the DriverManager.

Which I think means you would need to explicitly call setDriverType(String) on the "ods" reference.

So I suspect even if you have it in listener.ora, it will not be used when using this method of getting a connection.
Maybe you need to set some additional connect properties when using Oracle driver API direct method of connecting as proposed to using the DriverManager or JNDI?

http://download.oracle.com/docs/cd/E14072_01/appdev.112/e13995/oracle/jdbc/pool/OracleDataSource.html
Steven Schwab
Greenhorn

Joined: May 25, 2010
Posts: 9
I think you need to remove a line of code. Lines 31-32 (34-35 in your actual source, according to your stack trace), you have:


The error you are getting is on the call to defaultConnection():


Remove line 31 (conn = new oracle.jdbc.OracleDriver().defaultConnection();) and tell us what happens. I think you just want ods.getConnection() since you've configured ods with your Oracle URL.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Oracle10g: java.sql.SQLException: Invalid Oracle URL specified
 
Similar Threads
Problem in connecting Oracle thru Java
JDBC
Anyone please tell the reason for the following exception & how to solve it
Oracle.JDBC Connection Problem
connect oracle from java application