• 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

My interview question..

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you connect without the Class.forName (" ") ?
What does Class.forName return ?
can you provide answers for it?
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to both these questions can be found in the Javadocs for J2SE.
How do you connect without the Class.forName (" ")?
See Javadocs for java.sql.DriverManager
What does Class.forName return?
See Javadocs for java.lang.Class
Remember, Javadocs are your friend.
 
s ra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still not clear with the answer to the first question. can some one explain.
Also, would like to know about Isolation level in JDBC transaction. Any good link explaining all the isolation levels.
Thanks,
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class.forName() ensures that the driver you are using is loaded and registered with the JVM. When you are ready to create the actual connection, you will call getConnection() from the DriverManager class:
Connection conn = DriverManager.getConnection(connectionString);
At that time, the DriverManager class will see if there is a suitable driver registered. There should be since you loaded it with Class.forName().
 
Chris Mathews
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

From Javadocs for java.sql.DriverManager:
As part of its initialization, the DriverManager class will attempt to load the driver classes referenced in the "jdbc.drivers" system property. This allows a user to customize the JDBC Drivers used by their applications. For example in your ~/.hotjava/properties file you might specify:
jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver

A program can also explicitly load JDBC drivers at any time. For example, the my.sql.Driver is loaded with the following statement:
Class.forName("my.sql.Driver");


Therefore, if you don't want to explicitly use Class.forName() then you can specify the JDBC Driver as a system property called "jdbc.drivers".
 
s ra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did some research on net and found out that the below are same.
What do you all think?
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
same as
Class.forName ("oracle.jdbc.driver.OracleDriver");
Good link for Isolation levels in JDBC.
http://otn.oracle.com/oramag/oracle/02-jul/o42special_jdbc.html
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is 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