Applet - Er problemet driveren??
Jeg har lavet en applet der skal tilgå en MySQL og i et tekstarea skrive et rekordset.Men den kører ikke
Hvad er problemet? Er det et driver relateret problem?
Koden:
import java.sql.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
//Goto mysql.com and download the mm.mySQL Drivers.
//Unzip and copy mysql-connector-j-2.0.14-bin.jar to you CLASSPATH
//or into the same directory where all you .class files will lie.
//Here is a same code you should be able to figure it out.
public class Connector extends Applet implements ActionListener {
Button submit;
TextField txtKommentar;
TextArea txtAreal;
public void init(){
txtAreal = new TextArea("",20,50);
txtAreal.setEditable(false);
add(txtAreal);
txtKommentar = new TextField(50);
add(txtKommentar);
submit = new Button("Submit");
add (submit);
submit.addActionListener(this);
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3300/test", "root", "");
String query = "Select * from tbltest";
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(query);
while(rs.next()){
txtAreal.append(rs.getString(1));
}
con.close();
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
public void actionPerformed(ActionEvent e) {
String kommentar= txtKommentar.getText();
txtAreal.append(kommentar);
}
}