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

Home -> Community -> Usenet -> c.d.o.server -> Re: database connection with JDBC

Re: database connection with JDBC

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Wed, 25 Oct 2000 18:14:55 GMT
Message-ID: <39F72375.530372E6@rationalconcepts.com>

Welcome to java and Oracle.

   To get started off on the right foot with either, vist the http://www.javasoft.com site and learn, learn, learn.

   Then go and visit http://technet.oracle.com/sample_code/index.htm. You will need a technet account to browse the info, but those are free so sign up.

   Now, the error in your code is due to the syntax you are using:

            DriverManager.getConnection(
                  "jdbc:oracle:thin://42.221.200.200:1521/dw1",
                  "username",
                  "userID");

   (looks like mysql syntax...)
   anyway the corrected syntax is
    String usename = "scott";
    String userID = "tiger";
    DriverManager.getConnection(

                  "jdbc:oracle:thin:@42.221.200.200:1521:dw1",
                  username,
                  userID);

  If you wanted to alternately register the driver via the Class.forName(String s) method,

    String s = "oracle.jdbc.driver.OracleDriver";     Class.forName(s).newInstance();

   Good luck and please don't make the mistake of many by not reading the documentation.

hth,
cindy

dongbo_at_my-deja.com wrote:

> Hi,
>
> I'm new to JDBC and Oracle. I'm trying to access an Oracle8.1.6 server
> (NT) from another NT box by using jdbc-thin.
>
> First, registered the driver, which looked OK:
> DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
>
> Then, tried to connect to the database server, using
> Connection c = DriverManager.getConnection(
> "jdbc:oracle:thin://42.221.200.200:1521/dw1",
> "username",
> "userID");
> here, "dw1" is my database name. This failed.
>
> Can anybody tell me, what's wrong with my code?
>
> By the way, if I want to load db driver (thin) from method
> Class.forName(String s), what s will look like.
>
> I greatly appreciate all the answers/suggestions. Thanks.
>
> Dongbo Liao
> dliao_at_crl.nmsu.edu
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Wed Oct 25 2000 - 13:14:55 CDT

Original text of this message

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