• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne,

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

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic