jsp中的 pstmt.execute(); 不能执行问题!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/30 11:24:59
<%@ page import="java.sql.*" pageEncoding="GBK"%>
<%
Connection conn=null;
PreparedStatement pstmt=null;
String id=request.getParameter("id");
String xm=request.getParameter("xm");
String xh=request.getParameter("xh");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}
catch(Exception e){}
conn=DriverManager.getConnection("jdbc:odbc:mydb","sa","123456");
pstmt=conn.prepareStatement("update xh set xm=?,xh=? where id="+id);
pstmt.setString(1,xm);
pstmt.setString(2,xh);
pstmt.execute();
response.sendRedirect("7-11.jsp");
%>
问题:
这是一个修改页面,我的另一个7-11可以执行记录的插入,查询,删除,添加,都没有问题,就是这个修改出现了问题,办法都想过了,还是不行。。。。

Is Data Soruce Config?

sql语句写的不对吧。

感觉没有什么大问题,你最好把sql语句写出来打印一下sql语句并且打印一下你接所接的三个参数,看一下有没有什么细节上的错误。

改成这样试下
pstmt=conn.prepareStatement("update xh set xm=?,xh=? where id='"+id+"'");

你前面导入java.sql.*的包没有哦?