aspose file tools*
The moose likes JDBC and the fly likes confusion with drivers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "confusion with drivers" Watch "confusion with drivers" New topic
Author

confusion with drivers

vijaya bharath
Ranch Hand

Joined: Jun 10, 2005
Posts: 66
Hi,

can anyone explain me about these drivers and what exactly class.forname() is doing
what shud we use as an argument for class.forname()
and can't we write an appl to work with any database
that means if one organization db1,other db2
then my appl shud run for both
based on the parameters organization selects that db conn shuold perform
can anyone help me regarding


Regards,<br />Vijaya Bharath.<br />SCJP1.4 <br />SCWCD5.0
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
- what exactly class.forname() is doing?
Class.forName(String) loads the driver into memory.
- what shud we use as an argument for class.forname()?
The JDBC Driver class with complete path
eg: "oracle.jdbc.driver.OracleDriver"

- can't we write an appl to work with any database
If you mean without loading the driver? Yes and no. If you are writing standalone application then you need to configure somewhere so that your program can pickup and load the JDBC Driver. If the application is J2EE then you don't have to load the driver, container takes care of that. You use JNDI to get the connection directly.

- if one organization db1,other db2 then my appl shud run for both based on the parameters organization selects that db conn shuold perform can anyone help me regarding

Quick solution. Look at DAO pattern. You need to have DAO for each of the DB. If the database you are planning to use is ANSI complaint and you are not going to use DB specific syntax then you can have just DAO class.
[ June 08, 2006: Message edited by: Purushothaman Thambu ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
- if one organization db1,other db2 then my appl shud run for both based on the parameters organization selects that db conn shuold perform


DAOs abstract away the differences between databases, but they are only part of the answer. Different organizations would have different access modalities (driver, URL, username, password), so those need to be configured external to the code. It's common to keep those in a config file of some kind, so they can be easily changed.


Ping & DNS - updated with new look and Ping home screen widget
vijaya bharath
Ranch Hand

Joined: Jun 10, 2005
Posts: 66
Thanx for u r reply

with your explanation i understood that if that is not standard appl , then container will have all the drivers , am i correct?
can u clear me following things also......
is driver class name changes from db to db?
how to get to know the JDBC Driver class for the db we r using?
how can we say which type of driver it is(type1,type2...)?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
with your explanation i understood that if that is not standard appl , then container will have all the drivers , am i correct?

I'm not quite sure what you're asking. If by container you mean J2EE container, then no, those don't contain drivers - you'll have to add the appropriate jar files yourself.
is driver class name changes from db to db?

Yes.
how to get to know the JDBC Driver class for the db we r using?
how can we say which type of driver it is(type1,type2...)?

That's all in the documentation of the driver.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confusion with drivers
 
Similar Threads
Driver types
Thin drivers......??????
Struts - Checkbox
Why Loading of Driver is required in JDBC
jsp action