今天用jdbc on duplicate key update 做批量更新时候一直不成功,但是同样的sql语句在mysql的客户端工具以及命令行都能执行成功。情况大致如下// id:主键   reprints:转发数   comments:评论数
// 数据库还有一个标题字段:title varchar(255) NOT NULL// 目的id为:2245845和2245846的两天数据在数据库中已经存在,现在想要更新 reprints和comments 值分别为:(2245845,3,2),(2245846,4,1)insert into records (id,reprints,comments) values (2245845,3,2),(2245846,4,1) on duplicate key update reprints = values(reprints),comments = values(comments);该语句在客户端工具以及命令行都能执行成功,但是通过jdbc执行时报错:Field 'title' doesn't have a default valuejdbc操作如下:
Statement stat = connection.createStatement();
String sql = "insert into records (id,reprints,comments) values (2245845,3,2),(2245846,4,1) on duplicate key update reprints = values(reprints),comments = values(comments);";
stat.execute(sql);请各位大侠帮忙看看。