I am making a quartz thread application that is collect data from a table and insert it in another table after inserting it is updating the data base
but when i got the above error i got some of the data inserted twice in the table
Note that :
1.I use Oracle DB
2.**OJDBC6.jar to connect**
3.all tables are in same schema
StackTrace:
java.sql.SQLException: Connection is closed.
at org.apache.commons.dbcp.PoolingDriver$PoolGuardConnectionWrapper.checkOpen(PoolingDriver.java:263)
at org.apache.commons.dbcp.PoolingDriver$PoolGuardConnectionWrapper.close(PoolingDriver.java:268)
at com.sender.gsm.dao.Dao.closeConnection(Dao.java:38)
at com.sender.gsm.dao.OutDataDao.insertData(OutDataDao.java:91)
at com.sender.gsm.jobs.DataHandler.execute(DataHandler.java:49)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
The close connection function is
public void closeConnection(Connection conn) throws SQLException {
if (conn != null ) {
conn.close();
}
}
at com.sender.gsm.dao.Dao.closeConnection(Dao.java:38) at com.sender.gsm.dao.OutDataDao.insertData(OutDataDao.java:91)
From the stack traces ,you are closing the connection while performing the insert after select. try creating the new connection.
You might have called for closeConnection()
method after select statement.So an exception is thrown at runtime when it tried to execute the query the connection is closed.
If you are using connection pooling , make sure have configured the maxIdle
and maxActive
parameters to the reasonable values