Oracle数据库 spring手动控制事务 有时候执行 数据库会话会一直时inactive状态
不知道是代码问题还是数据库连接池的问题 各位大佬
java代码
public void ApprovalProtocol(ApprovalVo approvalVo) {
//事务
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = dataSourceTransactionManager.getTransaction(def);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
try {
//这里具体的业务代码 更新几个表
//提交事务
dataSourceTransactionManager.commit(status);
System.out.println("这里提交结束了---》"+simpleDateFormat.format(new Date()));
} catch (Exception e) {
e.printStackTrace();
dataSourceTransactionManager.rollback(status);
System.out.println("这里异常会滚结束了---》"+simpleDateFormat.format(new Date()));
throw e;
}
}
数据库连接池配置
spring.datasource.druid.connection-init-sqls=SELECT 1 FROM DUAL
--连接池的配置信息
spring.datasource.druid.initial-size=10
spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
spring.datasource.druid.test-while-idle=true
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.test-on-return=true
spring.datasource.druid.min-idle=5
spring.datasource.druid.max-active=50
spring.datasource.druid.max-wait=60000
spring.datasource.druid.time-between-log-stats-millis=60000
spring.datasource.tomcat.min-evictable-idle-time-millis=300000
spring.datasource.druid.filter.stat.slow-sql-millis=2000
spring.datasource.druid.filter.stat.log-slow-sql=true
spring.datasource.druid.pool-prepared-statements=true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size=50
spring.datasource.druid.connection-properties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=2000
spring.datasource.druid.min-evictable-idle-time-millis=600000
spring.datasource.druid.time-between-eviction-runs-millis=300000
#spring.datasource.druid.filters=stat,wall
spring.datasource.druid.filter.commons-log.statement-log-enabled=true
spring.datasource.druid.filter.stat.db-type=oracle
spring.datasource.druid.filter.wall.enabled=false
spring.datasource.druid.filter.wall.config.delete-allow=true
spring.datasource.druid.filter.wall.config.drop-table-allow=false
spring.datasource.druid.filter.log4j2.enabled=false
spring.datasource.druid.web-stat-filter.enabled=true
spring.datasource.druid.web-stat-filter.url-pattern=/*
spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
spring.datasource.druid.web-stat-filter.profile-enable=true