• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class.forName

 
harivarma mudunuru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic