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 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.