View Single Post
  #2 (permalink)  
Old 02-03-2008, 01:36 AM
jelly's Avatar
jelly jelly is offline
Member
 
Join Date: Jan 2008
Location: Somerset, UK
Posts: 46
jelly is on a distinguished road
You need to change your line of code

Code:
Class.forName("com.mysql.jdbc.Driver").newInstance ();
to

Code:
Class.forName("com.mysql.jdbc.Driver");
Your original code is trying to instantiate an instance of the driver and demands that it has a no argument constructor - which I do not believe it does have - but whether it has or not is beside the point as all you need to do is to cause the class to be loaded ( the new line of code does that) JDBC drivers have static blocks of code that register themselves with the DriverManager when they are loaded into the JVM, this means that the getConnection call will find them. Sorry went on a bit there

If it still fails then it means the JDBC driver is not available on the classpath
__________________
-- Hope that helps
Reply With Quote