I'm made a simple applet that will update MySQL using Connector/J (I've just started using JDBC and MySQL, so I'm on a very newbie level). When I run the applet from my compiler, it will open a java console and work correctly to update the database (there is an exception thrown, but the database is updated correctly).
Unfortunately, when I try to open the same applet from the same location in a web browser, the applet works but will not update the database.
Any suggestions?
public void actionPerformed(ActionEvent e) {
if (e.getSource() == left1) {
lscore = lscore + 1;
l = String.valueOf(lscore);
updateString = "UPDATE SCORE " +
"SET SCORE = " + l + " WHERE SIDE = 1";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///bball",
"root", "******");
st = con.createStatement();
st.executeUpdate(updateString);
while (rs.next()) {
}
}
catch (Exception d) {
System.err.println("Exception: " + d.getMessage());
}
finally {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (con != null) {
con.close();
}
}
catch (SQLException d) {
}
}
fleft.setText(l);
}
notes:
-the table name is score and the column I'm trying to update is named score- sorry for the confusing naming convention
-The SQL code was borrowed from a tutorial and I'm trying to make it fit. I don't have a ResultSet statement (rs) and I'm not sure how it works or if I even need it. But I am pretty sure that's why I'm getting an Exception: NULL ;-)
Thanks!