[jboss-user] [Beginners Corner] - Re: how get the datasource

PeterJ do-not-reply at jboss.com
Sun Aug 13 16:37:10 EDT 2006


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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964853#3964853

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964853



More information about the jboss-user mailing list