wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Connection Pooling in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Connection Pooling in Hibernate" Watch "Connection Pooling in Hibernate" New topic
Author

Connection Pooling in Hibernate

Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
Hi, anyone can help me how to get connection pooling in Hibernate, I am using Weblogic server8.1 server. I created a datasource there with pointbase database for test purpose. Now i have jndi name for that datasource.. I dont know how to call that datasource in hibernate..


Abu.A
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Just use the hibernate.connection.datasource property instead of defining a connection in your configuration. See the documentation for more.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
I read the article. I understood connection pooling. But Is it enough to mention only hibernate.connection.datasource in hibernate.properties??
Ranveer K Kumar
Ranch Hand

Joined: Sep 13, 2009
Posts: 64
Abubacker Siddik wrote:I read the article. I understood connection pooling. But Is it enough to mention only hibernate.connection.datasource in hibernate.properties??


add the connection pooling properties in the hibernate-mapping properties/xml file.
for in-build pooling:
hibernate.connection.pool_size

if you using the the third party liabrary for connection pooling like Apache DBCP then configure like this:

hibernate.dbcp.maxActive
hibernate.dbcp.maxIdle
hibernate.dbcp.maxWait
etc...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

None of the above is necessary if you are using a WebLogic DataSource. What Ranveer is suggesting is useful if you don't want to use WebLogic's DataSource and use DBCP.


I read the article. I understood connection pooling. But Is it enough to mention only hibernate.connection.datasource in hibernate.properties??

Yes. Or in hibernate.cfg.xml. Or programatically. Or as a System property passed at startup. Whichever suits your needs best.
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
Paul, One more doubt..weblogic datasource gives all the connection pooling configuration by default. So as Ranveer suggests, those properties are useful only if we use third parth jdbc connection pooling. But If i wanted to set minimum size of my connection pooling in weblogic datasource or max timeout for the connection..or whatever configuration properties..How can i configure weblogic datasource..?


Thanks in advance.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Its been years since I worked on WebLogic so I can't help I'm afraid. There's nothing you can do in Hibernate to influence this. I recommend having a read of the WebLogic documentation, that should tell you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection Pooling in Hibernate
 
Similar Threads
datasource?
Transactions in Tomcat
communication link failure revised
Hibernate with Application server connection pool
How do you connect to database(sql) from an ejb application