Java 批量入库,执行预处理并获得主键序列
?? ?java批量保存数据入库,主键序列自增长
?
public void batchSaveDetail(List listData) throws SQLException {Connection cn = null;PreparedStatement pstmt = null;String sql = "insert into log_sub_file_list " + " (LOG_SUB_FILE_LIST_ID,SUB_PATH,SUB_STATUS,SUB_DATA_NUM,SOURCE_FILE_ID) "+ "values (log_sub_file_list_seq.nextval,?,?,?)";cn = this.getConnection();pstmt = cn.prepareStatement(sql);for(int i=0;i<listData.size();i++){LogLockFileUnit lockFileUnit = (LogLockFileUnit) listData.get(i);int n = 1;pstmt.setString(n++, lockFileUnit.getFileName());pstmt.setString(n++, "0");pstmt.setString(n++, String.valueOf(lockFileUnit.getDataLength()));pstmt.addBatch();}pstmt.executeBatch();}