|
Re: Connecting to MySQL from Java JApplet
|
Posted: Apr 29, 2002 5:27 AM
|
|
> Hi, > > This could be a basic question. > > I am trying to establish an JDBC connection to MySQL > from my applet. It throws ClassNotFound Exception. > > But i am able to connect to MySQL Server through Java > Application. > > The class path is set properly. > > Below is the sample code. > > import javax.swing.*; > import java.awt.*; > import java.awt.event.*; > import java.sql.*; > import org.gjt.mm.mysql.*; > > public class Test extends JApplet{ > > public void init(){ > String DriverName = "org.gjt.mm.mysql.Driver"; > String DBUrl = "jdbc:mysql://localhost/TAPTool? > user=1155&password=test123"; > > try { > Class.forName(DriverName).newInstance(); > java.sql.Connection C = > = DriverManager.getConnection(DBUrl); > > C.close(); > } > catch (SQLException E) { > System.out.println("SQLException: " + > " + E.getMessage()); > System.out.println("SQLState: " + > " + E.getSQLState()); > System.out.println("VendorError: " + > " + E.getErrorCode()); > } > catch (ClassNotFoundException E){ > System.out.println("ClassNotFound: " + > E.getMessage()); } > catch (InstantiationException E) > {System.out.println("SQLException: " + > E.getMessage());} > catch (IllegalAccessException E) > {System.out.println("SQLException: " + > E.getMessage());} > > } > > } > > Error is ClassNotFound: org.gjt.mm.mysql.Driver
hi Sangeetha....
please include the mm mysql jar file in the archive attribute of "applet" tag. you won't get that problem.... If you feel still unclear...please feel free to mail me at keelypavan@yahoo.com
bye Pavan Kumar Keely Software Engineer, Quillis India
|
|