String sql = "update stuInfo set 学院 = '"+college+"' ,专业 = '"+profession+"' ,姓名 = '"+name+"' where 学号 = '"+id+"'";
其中
String college = new String(request.getParameter("college").getBytes("ISO-8859-1"),"UTF-8");
String profession = new String(request.getParameter("profession").getBytes("ISO-8859-1"),"UTF-8");
String id = new String(request.getParameter("id").getBytes("ISO-8859-1"),"UTF-8");
String name = new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
报错
javax.servlet.ServletException: 违反了 PRIMARY KEY 约束 'PK_stuInfo'。不能在对象 'dbo.stuInfo' 中插入重复键。
其中
String college = new String(request.getParameter("college").getBytes("ISO-8859-1"),"UTF-8");
String profession = new String(request.getParameter("profession").getBytes("ISO-8859-1"),"UTF-8");
String id = new String(request.getParameter("id").getBytes("ISO-8859-1"),"UTF-8");
String name = new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
报错
javax.servlet.ServletException: 违反了 PRIMARY KEY 约束 'PK_stuInfo'。不能在对象 'dbo.stuInfo' 中插入重复键。
解决方案 »
- Tomcat session数量能统计吗?
- spring+struts中找不到action,怎么弄啊,
- 问一个rmi的问题
- 向oracle中的blob字段插入数据老是包错,大家看看
- 谁会做?高手请进
- tomcat使用请教?
- 重装JB,WL遇到个问题
- 一个rmic的问题郁闷了我好几天!
- 哪位ggjj能给我提供几个关于jca标准的网址或者是书籍,易懂全面,适合初学者,谢谢各位!!!
- cas4.2.0限制用户登录错误次数及登录登出日志!急!急!急!
- 有人用存储过程么????????????????????????????????????????????????????????????????????
- 关于Spring配置事物管理的疑惑
你的update语句并没有修改pk! 所以你先确定你的id是否真的被获取了 其次确定你的id在数据库中是否也为字符串类型? 如果数据库中字符不为字符串,就得将id转变成相应类型 假设id为int类型:那么 String sql = "update stuInfo set 学院 = '"+college+"' ,专业 = '"+profession+"' ,姓名 = '"+name+"' where 学号 = "+id ;