CuchoBoy
|
Posted: 06/04/2005, 10:42 AM |
|
Quote kuldeep:
hello frnds
i do have in configuring the mysql
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
// Notice, do not import com.mysql.jdbc.*
// or you will have problems!
public class LoadDriver {
public static void main(String[] args) {
try {
// The newInstance() call is a work around for some
// broken Java implementations
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
// handle the error
}
}
it gives the exception:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
and using the following also
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
... try {
Connection conn = DriverManager.getConnection( "mysql","username","password");
....
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
gives the same exception:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
i have included the .jar file of the driver in to the web-inf/lib of the Tomcat and also in to the Java Home directory i.e. jre/lib/ext ....
and still facing these problems
plz do help me
Same problem here, plz help!!!
|
|
|
eserver221
|
Posted: 06/14/2005, 5:54 PM |
|
CuchoBoy,
you should set ENVRIOMENT VARIABLE CLASSPATH like this:
CLASSPATH=$CLASSPATH:/www/tomcat/common/lib/(yourdriver).jar (under Unix )
or
CLASSPATH = %CLASSPATH%; c:\tomcat\common\lib\(youardriver).jar
if you want to run the program above as a single application, you can put the jar file to any directory you like. but if you use tomcat as the jsp container you should put it in tomcat/common/lib, otherwise it would not work.
As far as how to include a jar into your CLASSPATH is concerned , you can refer to Think in Java 3rd. The book has an very specific explaination.
Best Regards
eserver220
|
|
|
revathi
|
Posted: 06/24/2005, 4:43 AM |
|
|
|
|
RFU3
|
Posted: 07/07/2005, 3:19 AM |
|
>Put jar in your classpath, either by adding the
>FULL path to it to your CLASSPATH enviornment variable, or putting it
>in $JAVA_HOME/jre/lib/ext.
Putting in $JAVA_HOME/jre/lib/ext solved my problem. I was getting Exception: com.mysql.jdbc.Driver
now its fine - great work, thanks dekacode
|
|
|
randomhelpfulperson
|
Posted: 07/07/2005, 7:38 AM |
|
I kept getting the com.mysql.jdbc.Driver exception (win xp pro sp2, java sdk 1.4.2.08) but I managed to fix it last night. The solution may work for you too:
In the CLASSPATH environment variable make sure there are no spaces. If your path needs to contain a space then put quotes around the entry,
eg
c:\file; d:\dir ect ory\file; e:\filename
becomes
c:\file;"d:\dir ect ory\file";e:filename
|
|
|
Victor Twomey
|
Posted: 07/16/2005, 7:29 AM |
|
After setting path and classpath correctly and moving jar file to jre lib ext file, the Load Driver program ran successfully. Thanks for the help. Now if I can only get the C api to cooperate with me I will be happy. Thanks for the tips. This was a helpful web site.
Regards,
Victor Twomey
|
|
|
|