This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
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: 18541

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
Similar Threads
Example drivers for all the 4 types of JDBC Drivers
SQL Server and real data type
JDBC DriverType & JTA
How to connect Oracle with Java