Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Different Database Drivers

 
ashishk kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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,
Ashish
 
Paul Clapham
Sheriff
Posts: 21137
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
Thanks,
Ashish
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic