This content has been marked as final. Show 1 reply
1 & 2) You should get the data source via JNDI, as follows:
InitialContext ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("PostgresDS"); Connection conn = ds.getConnection(); -- do stuff with the connection -- conn.close();
3) Yes. The close() method, above, returns the connection to the pool.
4) You have already done that. There are 5 initial connection established. You will have at most 100 connections. Though I can't remember off hand if the connections are established at server startup or the first time you attempt to access one. I think it is the later, in which case you could make initialization code in your app access a connection, that would get the connections established at server startup time.