I have a need to use connection pooling to manage connection. My application at the moment keeps creating connections for hibernate operations. We are closing connections after every DB operation. but as application is a standalone java code which runs multiple threads after a period the connection crosses the limit.
I have 2 queries
1) I tried using
but still connections goes out of maximum limit? Why doesn't hibernate's in built pooling mechanism respect this count.
2) My second query is is there any other connection pooling tool than c3p0?
3) As my application is a standalone java program, I won;t be able to use DataSource feature to get connections.. Is this understanding correct?
I believe to use DataSource the code has to be run inside an app server or web server where data source can be configured in a ejb.xml or web.xml deployment file.
Or is there a way to use a data source defined in some Weblogic / JBoss server on a different machine , in my java standalone program?
Please let me know.
Joined: Aug 25, 2008
I have found the solution of # 3- We can define a datasource in Weblogic server (or JBoss or other server) and use it in out standalone Java code which is using Hibernate.
The configuration would be as follows to use DataSource .
That's it !! I have created a data source in my local Weblogic with jndi name of java/MyDS. Only point to note is that you should have wlfullclient.jar in your classpath to read the WLInitialContextFactory.
I am still looking for a way to define datasource in a java program !!? Or is it not possible to use DataSource outside a web/ejb container?