File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes confirm JDBC Driver registration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "confirm JDBC Driver registration" Watch "confirm JDBC Driver registration" New topic

confirm JDBC Driver registration

Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
when we register a JDBC driver with java, say by doing Class.forName(..), how can we make sure tht the driver is registered? apart from checking for any exception? or do we assume that if no exception is thrown, then the driver registered successfully?

in other words, is there a way to find out all the drivers registered with a system?
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 354

Drivers register themselves with the DriverManager when loaded. This registration is mandated by JDBC specification and is done thru a static block of code that each driver implementation has. You can get the list of all registered drivers as DriverManager.getDrivers()
sarah khan

Joined: Apr 09, 2005
Posts: 2
what's mysql 's driver name is it for example


I am trying to connect to mysql and I have the above mentioned driver installed and am trying to connect to it I get no exceptions in registering it!!! but getting null exceptions when try to connect to it??? I tried the

and it printed

some sort of address (does not tell me a whole lot???)

here's the exact code I have to connect:

try {
String tURLString = "jdbc:mysql://localhost/empdb?user=root&password=admin";
boolean tStillTrying = true;
int tNumberOfTries = 0;
while (tStillTrying) {
try {
iConnection = DriverManager.getConnection(tURLString, "", "");
tStillTrying = false;
catch (Exception rException) {
tStillTrying = (tNumberOfTries > 20);
if ( iConnection == null )
System.out.println("iConnection is null");
System.out.println("got connected to the database");
anson cai

Joined: Apr 11, 2005
Posts: 2
Did you try?
String tURLString = "jdbc:mysql://localhost/empdb";
iConnection = DriverManager.getConnection(tURLString, "root", "admin");

or maybe your password and usrid is not matched?
I agree. Here's the link:
subject: confirm JDBC Driver registration
It's not a secret anymore!