shicf
6 天以前 5d2411baa5ae84890430a2d7e360fc6777054797
product-server-datasource/src/main/java/com/product/datasource/dao/impl/OracleDaoImpl.java
@@ -7,7 +7,6 @@
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;
@@ -19,8 +18,6 @@
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;
@@ -65,7 +62,7 @@
    }
    private void info(String message) {
        if (this.outLog) {
        if (this.outLog || "true".equals(Global.getSystemConfig("log.sql.print", "false")) ) {
            SpringMVCContextHolder.getSystemLogger().info(message);
        }
    }
@@ -89,7 +86,7 @@
            }
            return this.connection;
        } catch (Exception e) {
            e.printStackTrace();
           SpringMVCContextHolder.getSystemLogger().error(e);
            throw new BaseException(ErrorCode.GET_CONNECTION_FAIL, e);
        }
    }
@@ -138,6 +135,7 @@
            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);
        }
@@ -427,6 +425,7 @@
            pst.execute();
        } catch (Exception e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            throw new BaseException(ErrorCode.ADD_RECORD_FAIL, e);
        }
    }
@@ -486,6 +485,7 @@
                info("执行批量提交数据完成,共提交 " + data.getRows() + " 条,耗时:" + timer.intervalSecond() + " 秒 !");
                pst.clearBatch();
            } catch (Exception e) {
               SpringMVCContextHolder.getSystemLogger().error(e);
                throw e;
            } finally {
                connection.setAutoCommit(true);
@@ -532,11 +532,13 @@
                }
                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);
        }
    }
@@ -597,7 +599,7 @@
                int[] ints = pst.executeBatch();
                info("执行批量提交数据完成,共提交 " + data.getRows() + " 条,耗时:" + timer.intervalSecond() + " 秒 !");
                pst.clearBatch();
                if (isCommit) {
                if (isCommit && !connection.getAutoCommit()) {
                    connection.commit();
                }
                int successCount = 0;
@@ -610,14 +612,16 @@
                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();
            }
        } catch (Exception e) {
           SpringMVCContextHolder.getSystemLogger().error(e);
            throw new BaseException(ErrorCode.UPDATE_BATCH_ERROR, e);
        }
    }
@@ -688,6 +692,7 @@
            }
            return pst.executeUpdate();
        } catch (Exception e) {
           SpringMVCContextHolder.getSystemLogger().error(e);
            throw new OracleDaoImpl.BaseException(ErrorCode.EXECUTE_SQL_FAIL, e);
        }
    }