Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connecting applet to mysql database

Status
Not open for further replies.

daka94

Programmer
Apr 27, 2001
33
US
hai
i am using mm.mysql.jdbc 1.2c driver to connect Mysql database from applet.
i placed mysql_comp.jar file in the folder where i had my class files.
and my code is given below.i am getting classNotFoundException.
please help me.
thank u
public void connectDBase()
{

try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();

}catch (Exception E) {
E.printStackTrace();}
try{
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname");

}catch(Exception e){
System.out.println("unable to connect");
}
}
 
You must include the .jar in the classpath as well - if you have the .jar in the same folder as the classes you accomplish this via the following statement in DOS mode:

set classpath=%classpath%;.\mysql_comp.jar

You can also put the .jar anywhere else as long as you modify above statement to match the location.

Depending on your IDE or operating system you can also try to locate the classpath= in autoexec.bat or the NT environment variables - or you can try via IDE with something like "required librairies" (in JBuilder, will be something similar in other programs).

Hope this helps...
allow thyself to be the spark that lights the fire
haslo@haslo.ch - www.haslo.ch​
 
you can't connect an applet to a database (unless you are planning to use appletviewer all the way?)... guess you will have to change your system design...

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top