• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassNotFoundException out of nowhere!!

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am using MySQL, all the connection and queries have been working fine for quite sometime and than suddenly when i run my code today it gives me ClassNotFoundException, all the server settings are the same. I am using Tomcat4.
I am using a DBHandler class that creates and returns a connection object.
Its very frustrating, that it suddenly stops working.
Please HELP!!!
Gul
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has your system level classpath changed recently?
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing that tripped me up was that unbeknownst to me, this error is also caused by a firewall not letting the connection get through. Check if a new software firewall has been installed and/or that if it has 'always' been there, that parameters haven't changed pertaining to communications from your 'application' being BLOCKED, in both directions.
Along the same line as the classpath issue, that is another item that should be on your check list, did it get updated in one place but not the other?
Another question to ask is: "Did the code get changed?" Really, then analyze any refrences to the driver and its class.
I hope these few items will give you some insight on what I have, as a greenhorn, found in my frustrations.
Regards,
Gary J.
COS
 
Gul Khan
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most frustrated i m about is that its working in some parts, i have just added a new module to it yesterday. All my database code is seperate and has not been changed. NO recent classpath changes also and database settings are also the same as one month before.
The parts it is working in are some of the select queries. they are working fine as before but the insert and update queries when they try to fetch the connection from the same dbHandler class it returns a null connection.
Thanks for the tips by the way
 
Gul Khan
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my DBHandler class for getting the connection
/////////////////////////////////////////////
public class DBHandler {

private String dbClass="org.gjt.mm.mysql.Driver";
// .jar file for driver added to classpath
private String dbURL="jdbc:mysql://localhost:3306/dbName?user=admin&password=admin";

private Connection dbCon;
/** Creates a new instance of DBHandler */
public DBHandler() {
}

public java.sql.Connection getDbConnection()throws SQLException {
try{
Class.forName(dbClass).newInstance();
dbCon= DriverManager.getConnection(dbURL);
}catch(ClassNotFoundException e){

System.out.println("null Connection");
}catch(Exception e){
dbCon=null;
System.out.println("Instantiation or General Exception "+e.getMessage());
}

return dbCon;
}

public void close(java.sql.Connection con)throws SQLException{
try{
con.close();
}catch(SQLException e){System.out.println("Unable to Close the Connection");}
}

}
/////////////////////////////////////////////////////////
Each time i try to access DBHandler.getDbConnection it gives me the classnotfound exception.
I just checked my database out, and i hope u believe me that at database level all the data is updated and inserted but still my class throws a ClassNotFoundException. and i have no ideawhats going on here, coz it shouldnt be able to access the database if the connection is null:
[ September 20, 2003: Message edited by: pervaiz gul ]
 
I'm not sure if I approve of this interruption. But this tiny ad checks out:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic