我在xxamp中使用netbeans 8.2。 mysql connector.jar
是8.0.18。
它没有显示任何错误,但是每当我按下按钮时,jUsername中的值就不会插入,而是显示catch中的异常。请帮忙。
private void StartButtonActionPerformed(java.awt.event.ActionEvent evt) {
try {
String query = "INSERT INTO 'score' ('Name') VALUES (?)";
con = DriverManager.getConnection("jdbc:mysql://localhost/userscore", "root", "");
pst = con.prepareStatement(query);
pst.setString(1, jUsername.getText());
DifficultyPanel dpanel =new DifficultyPanel();
dpanel.setVisible(true);
this.dispose();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "Please Enter Your Username To Continue");
}
}