Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Deepak Kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Deepak Kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

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

 
Ed Ward
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic