File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Different Database Drivers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Different Database Drivers" Watch "Different Database Drivers" New topic

Different Database Drivers

ashishk kumar

Joined: Jan 29, 2008
Posts: 13
I am new to JDBC API.....
I googled "JDBC Tutorials" and I got several tutorials, but they mainly describe the 4 types of drivers and shows an example using jdbc-odbc driver.
Can anyone please show/guide me to tutorials/code snippets where I can see the type 4 driver in use(because its the fastest and the best).

How do I connect to a databse (preferably Oracle) using the type 4 driver?

Thanks in advance,
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

There is no point looking for "Oracle JDBC" tutorials. Just take the tutorials you have already read and replace the line of code that loads the JDBC-ODBC driver by a very similar line of code that loads the Oracle driver. That's the only change necessary. JDBC was designed specifically so that you could plug in different database drivers without having to change any other code.
ashishk kumar

Joined: Jan 29, 2008
Posts: 13
Yes but I am searching for "JDBC Tutorial" not "Oracle JDBC tutorials"

I know I can change the line where it says Class.forName("Oracle Class driver")
But I am trying to learn and know how to connect using driver 4 ? What would be the steps ?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

As Paul has already mentioned, there is no change. Change the driver class name and the JDBC URL and that is it. All your code will just work as is.

Check Oracle's JDBC documentation - its goes into quite a bit of detail.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
subject: Different Database Drivers
It's not a secret anymore!