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 21:42:14 GMT
Message-ID: <3872698B.51035CCA@rationalconcepts.com>


Hi Sam,
  Darn, the elves moved the document. I found it at http://technet.oracle.com/sample_code/tech/java/sqlj_jdbc/htdocs/templates.htm

Are you using the thin driver? Are you using the OCI driver?

If you don't have a technet account, sign up for one, they are free.

Anyway, this doc will show you both ways.

Cindy

Sam Fredland wrote:

> 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 - 15:42:14 CST

Original text of this message

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