Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loading JDBC driver

 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do we need to use Class.forName() to load a JDBC driver into the memory?
Is there any other method?
Can we use new operator to instantiate the Driver class.
 
gokul krishna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi amit,
Actually class.forName is the JDBC API in which u can register ur driver in the memory to connect into the Database. Even u can register more than one driver also.
Apart from this, u can also register using the oracle driver using the DriverManager class.
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
By doing the above also u can register your driver.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also define a "system" property (using the '-D' command-line option), but I forget the name of it. I think it is "jdbc.driver". In any case, you can find details in the Getting Started Guide.
Good Luck,
Avi.
 
David Gallardo
Author
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can instantiate the driver and register it as follows:
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Yet another way is to use the DataSource API.
@D
[ August 02, 2003: Message edited by: David Gallardo ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic