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 Class.forName() problem!! 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 "Class.forName() problem!!" Watch "Class.forName() problem!!" New topic

Class.forName() problem!!

ron mccarthy

Joined: Apr 29, 2004
Posts: 17
Hello people,
I have this problem when i try to connect to the database, unfortunately at this line:

I have this embedded in a try and catch but every time it throws an error back at me. I am convinced that it cant find the Driver but it is beyond me as to why, because I have put it in my classpath and installed it many times.
Please help me as soon as you can thanks,
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Please help me as soon as you can thanks,

Only if you post the stack trace the error generates.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ron mccarthy

Joined: Apr 29, 2004
Posts: 17
Here it is:

  • java.lang.ClassNotFoundException: com.mysql.jdbc.Driverat$
  • at Method)at
  • at java.lang.ClassLoader.loadClass( sun.misc.Launcher$AppClassLoader.loadClass(
  • at java.lang.ClassLoader.loadClass( java.lang.ClassLoader.loadClassInternal(
  • at java.lang.Class.forName0(Native Method)at java.lang.Class.forName(
  • at scms.Database.connect( scms.Database.queryDatabase(
  • at scms.logIn$ActionHandler.actionPerformed( javax.swing.AbstractButton.fireActionPerformed(
  • at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(
  • at javax.swing.DefaultButtonModel.fireActionPerformed( javax.swing.DefaultButtonModel.setPressed(
  • at javax.swing.plaf.basic.BasicButtonListener.mouseReleased( java.awt.Component.processMouseEvent(
  • at java.awt.Component.processEvent( java.awt.Container.processEvent(
  • at java.awt.Component.dispatchEventImpl( java.awt.Container.dispatchEventImpl(
  • at java.awt.Component.dispatchEvent( java.awt.LightweightDispatcher.retargetMouseEvent(
  • at java.awt.LightweightDispatcher.processMouseEvent( java.awt.LightweightDispatcher.dispatchEvent(
  • at java.awt.Container.dispatchEventImpl( java.awt.Window.dispatchEventImpl(
  • at java.awt.Component.dispatchEvent( java.awt.EventQueue.dispatchEvent(
  • at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
  • java.awt.EventDispatchThread.pumpEventsForHierarchy( java.awt.EventDispatchThread.pumpEvents( java.awt.EventDispatchThread.pumpEvents( not found on connection attempt

  • [ May 28, 2004: Message edited by: ron mccarthy ]
    Stefan Wagner
    Ranch Hand

    Joined: Jun 02, 2003
    Posts: 1923

    but it looks very much as a classpath-issue...

    Location of the Driver?
    Command to start the Application?
    echo $CLASSPATH (linux) echo %CLASSPATH% (win)
    echo $JAVA_HOME (linux) echo %JAVA_HOME% (win)
    It is sorta covered in the JavaRanch Style Guide.
    subject: Class.forName() problem!!
    It's not a secret anymore!