Re: JDBC

From: Sam Fredland <designinsites_at_home.com>
Date: 2000/01/04
Message-ID: <3872536F.A2DBA861_at_home.com>#1/1


Cindy,

Thanks, but I tried this Web site and got errors in both Netscape and IE. Oracle has a page on JDBC (go to www.oracle.com/java and click on JDBC & SQLJ) with references to 4 articles. Was it one of these? None of them seems relevant. They are:

JDBC: This document introduces JDBC and describes the three Oracle JDBC drivers. (not specific enough).

Accessing Oracle from Java: This document provides suggestions on when to use JDBC versus SQLJ to access data from an Oracle database.

Oracle8i JDBC Performance

An Overview of SQLJ: Embedded SQL in Java

What do you mean what driver am I using? I am using the oracle.jdbc.driver.OracleDriver driver. Is there some other piece of information I need to supply?

-Sam

"C. Ferguson" wrote:

> 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 - 00:00:00 CET

Original text of this message