| | |
| | | import com.product.core.config.Global; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | | import com.product.core.exception.BaseException; |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.datasource.config.DataBaseType; |
| | | import com.product.datasource.config.ErrorCode; |
| | |
| | | import com.product.datasource.utils.BatchUtil; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import java.lang.ref.PhantomReference; |
| | | import java.lang.ref.WeakReference; |
| | | import java.sql.*; |
| | | import java.util.List; |
| | | |
| | |
| | | } |
| | | |
| | | private void info(String message) { |
| | | if (this.outLog) { |
| | | if (this.outLog || "true".equals(Global.getSystemConfig("log.sql.print", "false")) ) { |
| | | SpringMVCContextHolder.getSystemLogger().info(message); |
| | | } |
| | | } |
| | |
| | | } |
| | | return this.connection; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | throw new BaseException(ErrorCode.GET_CONNECTION_FAIL, e); |
| | | } |
| | | } |
| | |
| | | ResultSet resultSet = pst.executeQuery(); |
| | | return loaddingDataList(resultSet); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | SpringMVCContextHolder.getSystemLogger().error("EXECUTE_ERROR_SQL:\n" + sql); |
| | | throw new BaseException(ErrorCode.GET_LIST_FAIL, e); |
| | | } |
| | |
| | | pst.execute(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | throw new BaseException(ErrorCode.ADD_RECORD_FAIL, e); |
| | | } |
| | | } |
| | |
| | | info("执行批量提交数据完成,共提交 " + data.getRows() + " 条,耗时:" + timer.intervalSecond() + " 秒 !"); |
| | | pst.clearBatch(); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | throw e; |
| | | } finally { |
| | | connection.setAutoCommit(true); |
| | |
| | | } |
| | | return pst.executeUpdate(); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | throw e; |
| | | } finally { |
| | | // this.closeConnection(); |
| | | } |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | throw new BaseException(ErrorCode.UPDATE_BATCH_ERROR, e); |
| | | } |
| | | } |
| | |
| | | int[] ints = pst.executeBatch(); |
| | | info("执行批量提交数据完成,共提交 " + data.getRows() + " 条,耗时:" + timer.intervalSecond() + " 秒 !"); |
| | | pst.clearBatch(); |
| | | if (isCommit) { |
| | | if (isCommit && !connection.getAutoCommit()) { |
| | | connection.commit(); |
| | | } |
| | | int successCount = 0; |
| | |
| | | batchResultEntity.setConnection(connection); |
| | | return batchResultEntity; |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | throw e; |
| | | } finally { |
| | | if (isCommit) { |
| | | if (isCommit && !connection.isClosed() && !connection.getAutoCommit()) { |
| | | connection.setAutoCommit(true); |
| | | } |
| | | // this.closeConnection(); |
| | | // this.closeConnection(); |
| | | } |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | throw new BaseException(ErrorCode.UPDATE_BATCH_ERROR, e); |
| | | } |
| | | } |
| | |
| | | } |
| | | return pst.executeUpdate(); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | throw new OracleDaoImpl.BaseException(ErrorCode.EXECUTE_SQL_FAIL, e); |
| | | } |
| | | } |