This discussion is archived
4 Replies Latest reply: Apr 27, 2012 8:19 AM by Mark Malakanov (user11181920) RSS

Oracle 11g RAC JDBC connection error

928147 Newbie
Currently Being Moderated
Hi,

I'm trying to run an installation which needs me to connect to an Oracle 11g RAC database. It's returning me an error:

Caused by: java.sql.SQLException: Invalid Oracle URL specified
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
     at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:538)

Our URL is:
jdbc:oracle:thin@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=+<IP1>+)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=+<IP2>+)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+<oracle_instance_name>+)))

We're using:
Java : jdk1.6_31
JDBC : odjbc14.jar
Oracle : Oracle 11g RAC

Is the driver compatible? If yes, could there be something wrong with our URL? Any other possibilities to help?

Thanks!
  • 1. Re: Oracle 11g RAC JDBC connection error
    gimbal2 Guru
    Currently Being Moderated
    925144 wrote:
    Caused by: java.sql.SQLException: Invalid Oracle URL specified
    Error seems pretty clear to me. Methinks you have to take a dive into the documentation again and compare the JDBC URL you have now to what is written in the specifications.
    We're using:
    Java : jdk1.6_31
    JDBC : odjbc14.jar
    Oracle : Oracle 11g RAC

    Is the driver compatible? If yes, could there be something wrong with our URL? Any other possibilities to help?
    Not really. ojdbc14 is a very old driver that was built for Java 1.4 and is designed to be used with Oracle 10g R2. If you use Oracle 11 and Java 6, use the matching ojdbc6 driver (the number in the driver name matches the Java major version).

    That doesn't mean it won't work, the database engine underneath doesn't change so much that it would have an influence on JDBC logic so it is possible that an older driver works just fine with a newer DBMS release when you use it purely for JDBC purposes. But I wouldn't like to take chances when its not necessary.
  • 2. Re: Oracle 11g RAC JDBC connection error
    928147 Newbie
    Currently Being Moderated
    Hi,

    Thanks for your reply. When you say "documentation", do you mean Oracle documentation on this JDBC specs?

    As for the driver, I did download ojdbc6.jar and tried. Still, it gave the same error. If there's any URL to the documentation, do you mind posting it here?

    Thank You!
  • 3. Re: Oracle 11g RAC JDBC connection error
    gimbal2 Guru
    Currently Being Moderated
    JDBC specs provide the API, do you want to know something about the API? No, you want to know how to configure the Oracle JDBC driver. I don't want to be a douche, but a little reasoning goes a long way.

    And of course there is an url, but I'd have to search for it. But that is something you can do too. Or you can just search google for "ojdbc connection url" until you see an example that matches your own setup. I must say that I've never seen a connection string with two hosts in it. Mine always look like this:

    jdbc:oracle:thin:@HOST:PORT:SID

    One connection, one SID.
  • 4. Re: Oracle 11g RAC JDBC connection error
    Mark Malakanov (user11181920) Expert
    Currently Being Moderated
    1. use ojdbc6.jar driver.

    2. With RAC it may make sense to use client side connection Load Balance.
    Otherwise first ADDRESS will be always tried first.

    jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_
    BALANCE=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=host-name-1)(PORT=1521))(ADDRESS=
    (PROTOCOL=TCP)(HOST=host-name-2)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=database-service-name)))

    3.
    +<oracle_instance_name>+
    use +<oracle_service_name>+

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points