Per the JMS spec, Connections are heavy-weight objects, and thus you want to create as few as possible. The general strategy is to create only one Connection. So...
1.) Get the JNDI InitialContext
2.) Look up the ConnectionFactory
3.) Obtain a Queue/TopicConnection from the ConnectionFactory
4.) Use the Connection factory method to create a Session. The JMS spec states that Session are not heavy-weight objects, so the general strategy is to partition your workload across several Sessions.
5.) Look up the destination
On an additional note, once you have looked up at ConnectionFactory or Destination there is no need to look it up again. Just hang on to the reference and keep using it.
Well, I have a doubt in this regard - is there any means of finding in the jboss server side and not in the database server side,
how many connections are there in the pool,
how many connections are in use and
how many connections are being returned at a given point of time?