-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: DataSource configuration with hibernate/jpa/tomcat 6/oracle
PostPosted: Tue Aug 04, 2009 8:45 am 
Newbie

Joined: Wed Mar 18, 2009 6:16 am
Posts: 4
Hello,
Should I need DataSource if my application works with hibernate/JPA/tomcat 6/oracle?
If no, how can I manage the database connections?
Does the Hibernate do this for me?
Here is my persistence.xml content:
Quote:
<persistence-unit name="appName" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect " />
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.username" value="usr" />
<property name="hibernate.connection.password" value="pass" />
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:XE" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.connection.characterEncoding" value="UTF-8" />
<property name="hibernate.connection.useUnicode" value="true" />
</properties>
</persistence-unit>


Top
 Profile  
 
 Post subject: Re: DataSource configuration with hibernate/jpa/tomcat 6/oracle
PostPosted: Mon Aug 10, 2009 7:04 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You will want to set up a connection pool, and use that in production. Using non-pooled connections is fine for testing.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: DataSource configuration with hibernate/jpa/tomcat 6/oracle
PostPosted: Wed Aug 12, 2009 7:52 am 
Newbie

Joined: Wed Mar 18, 2009 6:16 am
Posts: 4
Thanks a lot for your reply.
1. can you recommend on a good tutorial on the web for connection pooling in my case?
2. Does the connection opened by hibernate is being closed automatically after using it?
what could be the consequences of not using this connection pooling?
is it just for performance?


Top
 Profile  
 
 Post subject: Re: DataSource configuration with hibernate/jpa/tomcat 6/oracle
PostPosted: Wed Aug 12, 2009 9:06 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Quote:
2. Does the connection opened by hibernate is being closed automatically after using it?
what could be the consequences of not using this connection pooling?


Once a connection is finished, it is returned to the pool. The pool manages the timeouts.

Using a connection pool is one of the most resource and performance positive thing you can do in an application. Don't skip it!

-Cameron McKenzie

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: DataSource configuration with hibernate/jpa/tomcat 6/oracle
PostPosted: Thu Aug 13, 2009 2:43 am 
Newbie

Joined: Wed Mar 18, 2009 6:16 am
Posts: 4
Hi
I found here link to JDBC connections guide that gives some parameters to configure in order to use connection pooling such as:
Quote:
hibernate.connection.driver_class = org.postgresql.Driver
hibernate.connection.url = jdbc:postgresql://localhost/mydatabase
hibernate.connection.username = myuser
hibernate.connection.password = secret
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect

  • Does all this connection pooling isue is a mater of this kind of properties?
  • In which cases would I need datasource and what is the different between simple connection pooling managment and datasource?

Please regard both questions...
Thanks in advanced


Top
 Profile  
 
 Post subject: Re: DataSource configuration with hibernate/jpa/tomcat 6/oracle
PostPosted: Mon Aug 31, 2009 3:07 pm 
Newbie

Joined: Wed Mar 18, 2009 6:16 am
Posts: 4
I found a great tutorial of hibernate C3P0 open source connection pool:
https://www.hibernate.org/214.html
I just added the following lines to the persistence.xml and it worked greate:
Code:
         <!-- configuration pool via c3p0 -->
         <property name="c3p0.acquire_increment" value="1"/>
         <property name="c3p0.idle_test_period"  value="100"/><!-- seconds -->
         <property name="c3p0.max_size"  value="100"/>
         <property name="c3p0.max_statements"  value="0"/>
         <property name="c3p0.min_size"  value="5"/>
         <property name="c3p0.timeout"  value="100"/><!-- seconds -->

the tutorial explains each of these properties.
thanks a lot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.