java - 在 SQL 中使用批量更新时出现错误 MySQLNonTransientConnectionException
问题描述
以下鳕鱼:
String url;
ConnectionURL cURL= new ConnectionURL();
url=cURL.getCloudConnection();
try (Connection conn = DriverManager.getConnection(url))
{
Statement statement = conn.createStatement();
conn.setAutoCommit(false);
for(int i=9;i<updateCformValues.size()-1;i++){
List<Object> row=updateCformValues.get(i);
String JDECode =(String)row.get(0);
String CValue =(String)row.get(3);
String updatedata = "update CRdataTable set OutstandingCFormValue='"+CValue+"' where JDECode ='"+JDECode+"' ";
log("String"+i);
statement.addBatch(updatedata);
}
statement.executeBatch();
conn.commit();
}
}
catch (Exception e) {
// TODO: handle exception
out.print(e);
e.printStackTrace();
}
抛出异常
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed
请帮助我,谢谢。
解决方案
推荐阅读
- bash - 列表中的平均分
- python - 连接到 Redis 的 Azure 缓存时,Azure 环境变量从提供“无效密码”的键中删除最后一个字符 ('=')
- visual-studio - Visual Studio 分支比较给出误报。相同的文件被标记为不同
- r - 在 ggplotly 中使用 geom_tile 的颜色美学
- python - 如何在python中自动找到文件路径
- javascript - JavaScript 生成的 Materialise 卡片显示问题
- metaprogramming - 元类的元类?
- google-chrome - Autodesk forge 查看器将样式设置为镶边在 chrome 显示错误
- r - 缺少参数“x”,ezANOVA 中没有默认值
- airflow - 为什么Airflow在清除其他任务时会重新安排当时不存在的任务