你好,想问你个问题,我在jsp中根据input text输入的值 修改数据库 无法实现啊,
id是request.getParameter("")获取的另一个页面的,下面是<%java%>,都写在了一个jsp中,想实现修改;<%try{Class.forName...
id是 request.getParameter("")获取的另一个页面的,下面是<%java%>,都写在了一个jsp中,想实现修改;
<% try{
Class.forName(DRIVER);
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
String id1=request.getParameter("id");
String user_name1=request.getParameter("user_name");
String user_pwd=request.getParameter("user_pwd");
String organization1=request.getParameter("organization");
Connection con = DriverManager.getConnection(URL,USER,PASS);
Statement stat =null;
ResultSet rs =null;
stat =con.createStatement();
String updateSql="update user set user_name="+user_name1+",user_pwd="+user_pwd+",organization="+organization1+"where id="+id1+"";
stat.execute(updateSql);
rs =stat.executeQuery("select * from user where id="+id1+"");
%>
submit 提交的完,数据库没改变,不知道什么原因。。求助! 展开
<% try{
Class.forName(DRIVER);
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
String id1=request.getParameter("id");
String user_name1=request.getParameter("user_name");
String user_pwd=request.getParameter("user_pwd");
String organization1=request.getParameter("organization");
Connection con = DriverManager.getConnection(URL,USER,PASS);
Statement stat =null;
ResultSet rs =null;
stat =con.createStatement();
String updateSql="update user set user_name="+user_name1+",user_pwd="+user_pwd+",organization="+organization1+"where id="+id1+"";
stat.execute(updateSql);
rs =stat.executeQuery("select * from user where id="+id1+"");
%>
submit 提交的完,数据库没改变,不知道什么原因。。求助! 展开
1个回答
展开全部
String updateSql="update user set user_name="+user_name1+",user_pwd="+user_pwd+",organization="+organization1+"where id="+id1+"";你这个语句写的就不太合适。目测,where前面至少应该有个空格,你可以打印出来,在控制台看看这个语句。
追问
谢谢,已经解决了,是这个语句的问题,拼接 user_name='"+user_name+"'
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询