File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes class.forName Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "class.forName" Watch "class.forName" New topic
Author

class.forName

harivarma mudunuru
Greenhorn

Joined: Sep 07, 2000
Posts: 8
what is the need for Class.forName() method to connect to database using java? And what is the meaning of su.jdbc.odbc.Jdbc OdbcDriver that I am giving as a parameter in Class.forName method?
Apu Nahasapeemapetilon
Ranch Hand

Joined: Sep 06, 2000
Posts: 51
Gonna need to see some code on this one, as there is no need for 'Class.forName()' to connect to any DB.
You do need to know the JDBC driver (among other things) to use as a property of the Connection object (so it know what to use) to connect to the DB.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
There are two ways register load a driver.
If you are new to JDBC .. stick with Class.forNames() for now.
Please review the java doc's or review one of the book
referenced at the top of this form...
Quick Summary:
1 jdbc has a driver manager to manages all data source connections weather they be type 1, 2, 3, or 4.
2 Class.forNames() register and load the driver to connect to you data source.
3 i use data source instead of database because jdbc 2.0 make it very easy to access any tabluar file. db engine is not required.
My i recommend you review the tutorials...
Pickup one of the book listed at the top of this form...
Spend a few days reading...
presently I am reading the 'JDBC API Tutorial ...'
We are all here to help one another...
Till next time...
Monty6
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi! Hari,
Class.forname is used to sepcify to load the JDBC drivers.
and the sun.jdbc.odbc.JdbcOdbcDriver specifies that u r using JDBD_ODBC bridge driver to connect to databases.There are 4 types of drivers to connect to database.For details on types of drivers check up any book
satya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class.forName