aspose file tools*
The moose likes Object Relational Mapping and the fly likes Using Hibernate with DataSource or connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Using Hibernate with DataSource or connection pool" Watch "Using Hibernate with DataSource or connection pool" New topic
Author

Using Hibernate with DataSource or connection pool

hildich kilal
Ranch Hand

Joined: Aug 25, 2008
Posts: 44
Hello,
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
hibernate.connection.pool_size=50

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.

Thanks

hildich kilal
Ranch Hand

Joined: Aug 25, 2008
Posts: 44
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?

HK.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Hibernate with DataSource or connection pool