连接数据库删除表中数据
servlet代码:
DbUtil代码:
package model_db;
import java.sql.*;
public class DbUtil {
private Connection con=null;
private PreparedStatement pstm=null;
private ResultSet rs=null;
public int updateSQL(String sql){
int n=-1;
try{
con=DBConnection.getDBconnection();
pstm=con.prepareStatement(sql);
n=pstm.executeUpdate();
}catch(SQLException e){e.printStackTrace();}
DBConnection.closeDB(con,pstm,rs);
return n;
}
public ResultSet QuerySQL(String sql){
try{
con=DBConnection.getDBconnection();
pstm=con.prepareStatement(sql);
rs=pstm.executeQuery();
return rs;
}catch(SQLException e){
e.printStackTrace();
}return null;
}
}
jsp代码:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>名片删除</title>
</head>
<body>
<h1 align="center">名片删除</h1><hr><br>
<center><form action="yonghuSC" method="post">
姓名:<input name="nameS"><br><br>(请输入姓名电话,点击修改名片即可删除个人所有信息)<br><br>
电话:<input name="callS"><br><br>
<input type="submit" value="删除"><br><br><a href="mingpian.jsp">返回查询</a>
</body>
</html>
可以运行但是删除不了 一直是删除失败 数据库表也没有变化
期末作业..求大神帮帮忙