日期:2014-05-19 浏览次数:20770 次
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '8,10,11'
public ActionForward submitApply(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws SQLException {
String[] ids = request.getParameterValues("ids");
String str = "";
for (int i = 0; i < ids.length; i++) {
str += ids[i];
if(i<ids.length-1){
str += ',';
}
}
System.out.println(str);
RefundDao.submitApply(request.getParameter("uid"), str);
return mapping.findForward("applylist");
}
public static void submitApply(String uid,String str) throws SQLException {
BaseConnection con = new BaseConnection();
Connection conn = con.getConnection();
String sql ="UPDATE refund SET state=1 where id in(?);";
PreparedStatement stmt = (PreparedStatement) conn.prepareStatement(sql);
stmt.setString(1, str);
stmt.executeUpdate();
}
UPDATE refund SET state=1 where id in(8,10,11);没有错误。
public static void submitApply(String uid,String str) throws SQLException {
BaseConnection con = new BaseConnection();
Connection conn = con.getConnection();
String sql ="UPDATE refund SET state=1 where id in("+str+");";
PreparedStatement stmt = (PreparedStatement) conn.prepareStatement(sql);
stmt.executeUpdate();
}