更新语句错了么?
JDBC实现数据库数据修改
可以执行,可是执行了该行的列值没有改变,也不报错
请问是不是更新语句错哪了?
<%
request.setCharacterEncoding("GB18030");
String s = request.getParameter("id");
String twm = request.getParameter("t5");
String wz = request.getParameter("t6");
if(twm !=""&& wz!="" ){
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/justshow?user=root&password=123");
Statement stmt = conn.createStatement();
stmt.executeUpdate("update xueyi set weizhi='"+twm+"',jiawei='"+wz+"'where tanwei='"+s+"'");
stmt.close();
conn.close();
response.sendRedirect("zhu.jsp");
}else{
response.sendRedirect("xue12.jsp");
}
%>
[解决办法]
你把这段代码改成这样 如下
Connection conn = null;Class.forName("com.mysql.jdbc.Driver");conn = DriverManager.getConnection("jdbc:mysql://localhost/justshow?user=root&password=123");Statement stmt = conn.createStatement(); stmt.executeUpdate("update xueyi set weizhi='"+twm+"',jiawei='"+wz+"'where tanwei='"+s+"'"); stmt.close();conn.close();
[解决办法]