我将数据插入名为comp的MySQL表中。数据插入正常,但我在下一行插入了一行零。知道什么可能是错的吗?
插入数据的代码:
String ret = ERROR;
Connection con = null;
try {
String URL = "jdbc:mysql://localhost/golfclub";
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(URL, "root", "root");
PreparedStatement ps = con.prepareStatement("insert into comp values (?,?,?)");
ps.setString(1, getName());
ps.setInt(2, getHandicap());
ps.setInt(3, getTotalPoints());
ps.executeUpdate();
ret = SUCCESS;
} catch (Exception e) {
ret = ERROR;
} finally {
if (con != null) {
try {
con.close();
} catch (Exception e) {
}
}
}
return ret;
}