• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Using Hibernate with DataSource or connection pool

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Look ma! I'm selling my stuff!
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!