在SQL中使用批处理更新时出现错误MySQLNonTransientConnectionException

时间:2018-11-18 15:37:32

标签: java mysql jdbc

以下鳕鱼:

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

请帮助我,谢谢。

0 个答案:

没有答案