在java程序中,创建一个按钮,其功能为点击按钮,清空前面所添加的记录 5
大致代码如下,应该怎样修改??求指导privatevoidjButton4ActionPerformed(java.awt.event.ActionEventevt){t...
大致代码如下,应该怎样修改??求指导
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
try {
String url = "jdbc:mysql://localhost:3306/aaa";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(url, "root", "19920701");
Statement stmt = conn.createStatement();
String sql = "delete * from payoutlist";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
jTextField1.setText("");
return;
}
} catch (Exception e) {
System.out.printf(e.getMessage());
}
}
需要清空的就是像最上面那两行一样添加上的记录,吧数据库的表清空之后上面的记录还会在吗?? 展开
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
try {
String url = "jdbc:mysql://localhost:3306/aaa";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(url, "root", "19920701");
Statement stmt = conn.createStatement();
String sql = "delete * from payoutlist";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
jTextField1.setText("");
return;
}
} catch (Exception e) {
System.out.printf(e.getMessage());
}
}
需要清空的就是像最上面那两行一样添加上的记录,吧数据库的表清空之后上面的记录还会在吗?? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询