This content has been marked as final. Show 3 replies
Edward D.G. wrote:You can do so by setting maxIdle time for the datasource.
I created this oracle conection:
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/produccionDS");
How can i set it for it close automatically in 20 second after it be uses it.?
You'd have to schedule some parallel timed job to fire after 20 seconds and close the connection. I've never done that (its a bit of a questionable requirement if you ask me), so I can't say what will happen when you try to close a connection while there is a statement still running on it. You'll likely at least get an SQLException on the thread that is executing the statement.1 person found this helpful
You can do so by setting maxIdle time for the datasource.That would work if the requirement is to close the connection when it is in fact idle; the OP made me think otherwise.
Can you write the example what do you say???