首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java 批量处置

2012-10-28 
java 批量处理public boolean iswhile(ListString sql){boolean isTrue falseConnection conn null

java 批量处理
public boolean iswhile(List<String> sql){
    boolean isTrue = false;
    Connection conn = null;
//    Statement stmt = null;
    PreparedStatement pstmt=null;
    try{
    conn = this.getConnection();
    conn.setAutoCommit(false);
    for(int i = 0;i<sql.size();i++){
    System.out.println("SQL " + sql.get(i));
    pstmt = conn.prepareStatement(sql.get(i));
    pstmt.addBatch();
    }
    pstmt.executeBatch();
    conn.commit();
    isTrue = true;
    }catch(Exception ex){
    try {
conn.rollback();
} catch (SQLException e) {
e.printStackTrace();
}
    }
   
    return isTrue;
    }

热点排行