AnsweredAssumed Answered

MyBatis closed db connection

Question asked by aitor on Mar 3, 2014
Latest reply on Mar 10, 2014 by jbarrez
Hello!!!

Every morning I see a DB connection error trace in my logs before doing any operation.
After doing some operation the error disappears (MyBatis reestablishes the connection).
Everything works fine, but there are many traces of error in my logs.

How I can avoid this?

This is my ProcessEngine configuration:


String jdbcUrl = "jdbc:oracle:thin:@192.168.2.1:1521:MYDATABASE";
String jdbcDriver = "oracle.jdbc.OracleDriver";
String jdbcUsr = "myuser";
String jdbcPwd = "mypwd";

ProcessEngineConfiguration processEngineConfig = ProcessEngineConfiguration
   .createStandaloneProcessEngineConfiguration()
   .setJdbcUrl(jdbcUrl)
   .setJdbcDriver(jdbcDriver)
   .setJdbcUsername(jdbcUsr)
   .setJdbcPassword(jdbcPwd)
   .setJobExecutorActivate(true)
   .setHistory(HistoryLevel.FULL.getKey());


And this is the exception I see every morning:


04:52:00,608 ERROR [org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable] (Thread-73) exception during job acquisition:
### Error querying database.  Cause: java.sql.SQLException: Excepción de E/S: The Network Adapter could not establish the connection
### The error may exist in org/activiti/db/mapping/entity/Job.xml
### The error may involve org.activiti.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
### The error occurred while executing a query
### Cause: java.sql.SQLException: Excepción de E/S: The Network Adapter could not establish the connection
04:53:01,619 ERROR [org.activiti.engine.impl.interceptor.CommandContext] (Thread-73) Error while closing command context: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.sql.SQLException: Excepción de E/S: The Network Adapter could not establish the connection
### The error may exist in org/activiti/db/mapping/entity/Job.xml
### The error may involve org.activiti.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
### The error occurred while executing a query
### Cause: java.sql.SQLException: Excepción de E/S: The Network Adapter could not establish the connection
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) [mybatis-3.2.2.jar:3.2.2]
   at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:286) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:277) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:272) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:259) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.persistence.entity.JobEntityManager.findNextJobsToExecute(JobEntityManager.java:105) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:48) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:33) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) [activiti-engine-5.14.jar:5.14]
   at org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable.run(AcquireJobsRunnable.java:59) [activiti-engine-5.14.jar:5.14]
   at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]
Caused by: java.sql.SQLException: Excepción de E/S: The Network Adapter could not establish the connection
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.2.0"]
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.2.0"]
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.2.0"]
   at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.2.0"]
   at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:420) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.2.0"]
   at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.2.0"]
   at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.2.0"]
   at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.2.0"]
   at java.sql.DriverManager.getConnection(DriverManager.java:579) [rt.jar:1.7.0_17]
   at java.sql.DriverManager.getConnection(DriverManager.java:190) [rt.jar:1.7.0_17]
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:180) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:175) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:79) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:373) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:82) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:131) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:58) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:271) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:69) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) [mybatis-3.2.2.jar:3.2.2]
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) [mybatis-3.2.2.jar:3.2.2]
   … 15 more


Thanks for the help,
Aitor.

Outcomes