• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC and JRE

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) When we load the JDBC Drivers, what is happening in JRE of both client and the Server?
2) What is the Difference between loading the drivers using Class.forName() and Driver.registerDriver() methods?
3) Why do we need Type-1 to Type-4?. Why dont we use single Driver for ALL?.
4) Difference between 'Statement', PreparedStatemet and CallableStatement?
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Senthamizh Selvan:
1) When we load the JDBC Drivers, what is happening in JRE of both client and the Server?


Nothing on the server. In the client, the driver classes are loaded from the classpath.


2) What is the Difference between loading the drivers using Class.forName() and Driver.registerDriver() methods?


Calling registerDriver() causes the driver class to be registered twice. This is because the driver class is required by the JDBC spec to register itself. Then registerDriver() registers the class again. Class.forName() is the preferred way to explicitly load and register the driver. This is not the only way to load the drivers.


3) Why do we need Type-1 to Type-4?. Why dont we use single Driver for ALL?.


Why don't we all use the same programming language? There are different solutions for different requirements. Type 1 is used when you have an ODBC driver but no JDBC driver other than Type 1. Type 2 is considered to be fast (this may or may not be true for your driver) because it uses native code, but it is also platform specific. Type 4 is pure Java so it can be used with any platform that has a JVM or JRE. Type 3 is used when you must access the database through another server layer.


4) Difference between 'Statement', PreparedStatemet and CallableStatement?[/QB]


Statement - used for most SQL commands
PreparedStatement - used for SQL commands that are frequently reused with different data values
CallableStatemenet - used to call stored procedures.
Most of these questions are probably answered at the Java JDBC tutorial at http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html or the Getting Started Guide at http://java.sun.com/j2se/1.4/docs/guide/jdbc/getstart/GettingStartedTOC.fm.html
 
Don't play dumb with me! But you can try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic