...

View Full Version : MySQL in Netbeans



proffittcenter
09-14-2008, 10:41 AM
I have a Java program developed in Netbeans which successfully connect to a MySQL database.
It should also run when I double click the buit jar file, but in this case gives an error:
java.lang.ClassNotFoundexception:com.mysql.Driver
I have gone over the step a number of times given in various tutorials but cannot find the cause. Any suggestions would be greatly appreciated.

shyam
09-14-2008, 03:06 PM
is the driver jar for mysql in the classpath? or have u included it inside the jar that you built and added the class-path attribute in the manifest file?

proffittcenter
09-14-2008, 03:13 PM
I have tried putting it in the classfile but it made no difference. It is included in the jar file.
'added the class-path attribute in the manifest file?' not sure what is needed here. I have never looked at the manifest file so will get back to you on this.

proffittcenter
09-14-2008, 03:43 PM
From the manifest file, I have:
Class-Path: lib/swing-layout-1.0.3.jar lib/ostermillerutils_1_06_01.ja
r lib/napkinlaf-swingset2.jar lib/napkinlaf.jar lib/mysql-connector-j
ava-5.1.0-bin.jar lib/jcalendar-1.3.2.jar lib/looks-2.0.1.jar lib/utc
_jpos_common_101.jar lib/beansbinding-1.2.1.jar lib/comm.jar lib/jasp
erreports-2.0.2-applet.jar lib/jasperreports-2.0.2-javaflow.jar lib/j
asperreports-2.0.2.jar
or more simply
lib/mysql-connector-java-5.1.0-bin.jar
This seems to be wrong version so will try changing it to the correct one.
Change made no difference.
Manifest seems to contain things that have since been removed and connector was an old version. Is it possible to re-generate the manifest?

shyam
09-14-2008, 04:20 PM
This seems to be wrong version so will try changing it to the correct one.
Change made no difference.
Manifest seems to contain things that have since been removed and connector was an old version. Is it possible to re-generate the manifest?

yes you can modify the manifest by simply creating the jar again with the correct manifest attributes. if you are using ant to build then you might have to update the manifest entries specified in your build.xml

proffittcenter
09-14-2008, 04:25 PM
Thanks for pointing me in the right direction. Never touched Ant - leave Netbeans to do all that sort of stuff. Having messed up my copy of the manifest, I copied an empty manifest from another program and then on build it re-generated with correct inclusions and all works now. Thanks again, this has delayed me for more time than I would like to admit.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum