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: Will Oracle 9i let me connect using jdbc right "out of the box"

Re: Will Oracle 9i let me connect using jdbc right "out of the box"

From: James <lawless_at_maths.tcd.ie>
Date: 13 Aug 2002 09:47:10 -0700
Message-ID: <1648709d.0208130847.46f70ce1@posting.google.com>


Hi,

I have sympathy for you having often been in that situation myself not so long ago (recent graduate :-)

Should I be able to get my java program to connect > without
> > installing anyting else?

Well obviously you'll have to write some code but, no that should be it. I'm not sure about Oracle Personal server or whatever it's called, I'm more used to the enterprise versions but generally you have a server running on one machine and a client running on another machine. You generally have to have the client installed on the machine you're running Java on before it will connect. (Correct me if I'm wrong anyone?)

I imagine the personal version has all that taken care of with client and server on one machine. If Toad will run then you can make a connection so you should be OK. You will also need to have a JDBC driver. See below.

> > know how to connect to a database is by (I'm using windows) going to the
> > control panel, starting the odbc DSN utility and making a new DSN. I can

>  see

> > that there is definately a driver and I can set up a dsn from there. But
> it
> > doesnt work.

That's one way of doing it. What you're doing there is registering Oracle as a Windows (ODBC) data source whereby Windows makes the datasource available through a central location for whatever wants to use it. To talk to this in Java you will need to get Java talking to the Windows ODBC source and for this you need to make a JDBC-ODBC bridge. You can use the JdbcOdbcDriver class which comes standard with the JDK (Java). e.g.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:datasourcename",username,password);

Each database also supplies its own JDBC drivers (including Oracle) and you can simply talk to the database through Java using those.

There's a whole load of stuff you have to to then, load your driver, use DriverManager, get an instance, etc. but you probably know that. Otherwise the Oracle docs might be a bit much but try the JDBC short tutorial on Sun. Or just search Google for JDBC tutorial and that'll fill in the rest.

Any more problems, post your code here and we'll have a look.

Good luck,

James Received on Tue Aug 13 2002 - 11:47:10 CDT

Original text of this message

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