problem connecting to mysql with applet
hey guys, java newbie here...
Having some trouble connecting to a mysql database located on my local box. Simple,, no username/password, just playing around and trying to connect. Pertenant information: JDK 1.5.0_6, Netbeans IDE 5.0, Mysql. I'm running a java applet, and I'm able to get a connection just fine when I run the applet from the IDE, but not when I go to the web browser. Heres my code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author hobeau
*/
publicclass NewAppletextends java.applet.Applet{
/** Initializes the applet NewApplet */
publicvoid init(){
try{
java.awt.EventQueue.invokeAndWait(new Runnable(){
publicvoid run(){
initComponents();
}
});
}catch (Exception ex){
ex.printStackTrace();
}
}
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
privatevoid initComponents(){
jFrame1 =new javax.swing.JFrame();
jLayeredPane1 =new javax.swing.JLayeredPane();
jButton1 =new javax.swing.JButton();
jLabel1 =new javax.swing.JLabel();
setLayout(new java.awt.BorderLayout());
jButton1.setText("jButton1");
jButton1.addMouseListener(new java.awt.event.MouseAdapter(){
publicvoid mouseClicked(java.awt.event.MouseEvent evt){
jButton1MouseClicked(evt);
}
});
jButton1.setBounds(20, 50, 73, 23);
jLayeredPane1.add(jButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLabel1.setText("jLabel1");
jLabel1.setBounds(10, 10, 240, 14);
jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
add(jLayeredPane1, java.awt.BorderLayout.CENTER);
}// </editor-fold>
privatevoid jButton1MouseClicked(java.awt.event.MouseEvent evt){
try{
Class.forName("org.gjt.mm.mysql.Driver");
Connection databaseConnection = DriverManager.getConnection("jdbc:mysql://localhost/test");
jLabel1.setText(databaseConnection.toString());
}catch(ClassNotFoundException cnfe){
jLabel1.setText(cnfe.toString());
}catch(SQLException sqle){
jLabel1.setText(sqle.toString());
}
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JFrame jFrame1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLayeredPane jLayeredPane1;
// End of variables declaration
}
As you can see, this is about as basic as it gets. I downloaded the connection drivers from mysqls website and loaded them and it works fine when I run it from the IDE. But when I try to run it from the web browser, I get an error message that says "java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver". I'm sure I'm doing something stupid, but I'm not quite sure what. Can anyone help? Thanks!

