Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: JDBC

Re: JDBC

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Tue, 04 Jan 2000 16:51:47 GMT
Message-ID: <38722576.65DF8451@rationalconcepts.com>


Hi Sam,
  since you didn't specify what driver you are using, I'm going to refer you to a white paper on the oracle site.

Please see http://www.oracle.com/java/jdbc/templates.html

cheers.
cindy

Sam Fredland wrote:

> Hi,
>
> I'm trying to get a Java servlet up and running (written by somebody else)
> using JDK 1.2 and Apache 1.3 with JServ. When I invoke it, I get the error:
>
> java.sql.SQLException: Invalid Oracle URL specified: OracleDriver.connect
>
> I'm passing "jdbc:oracle:myp.di" (without the quotes) as my URL and a
> username and password to the database myp (also the ORACLE_SID). I also
> tried "jdbc:oracle:myp". I have no idea whether this is the correct form of
> the URL--I am basing it on the code, which checks that the string starts
> with "jdbc" followed by a colon, followed by "oracle" or "odbc" followed by
> another colon, and, I assume, something to indicate which database to
> connect to.
>
> The error is occurring in the call to DriverManager.getConnection in the
> code below.
>
> Does anyone know the correct form of the DB URL?
>
> -Sam Fredland
>
> Code
> ====
>
> private static HashMap driverNames;
>
> static {
> driverNames = new HashMap();
> driverNames.put("odbc", "sun.jdbc.odbc.JdbcOdbcDriver");
> driverNames.put("oracle", "oracle.jdbc.driver.OracleDriver");
> }
>
> public static XConnection getConnection(String dbURL, String username,
> String passwd) {
> if( !dbURL.startsWith("jdbc:") ) {
> throw new DataBaseException("Bad URL " + dbURL);
> }
> String code = dbURL.substring(5).substring(0,
> dbURL.substring(5).indexOf(":"));
> String className = (String)driverNames.get(code);
>
> try {
> Class.forName(className);
> } catch (Exception e) {
> e.printStackTrace();
> throw new DataBaseException("Cannot load Driver " +
> className);
> }
> try {
> Connection conn = DriverManager.getConnection(dbURL, username,
> passwd);
> return new XConnection(conn);
> } catch (SQLException e) {
> e.printStackTrace();
> throw new DataBaseException(e.getMessage());
> }
> }
Received on Tue Jan 04 2000 - 10:51:47 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US