-->
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.  [ 1 post ] 
Author Message
 Post subject: Best Practice JNDI Datasource vs Third party Connection Pool
PostPosted: Wed Dec 15, 2010 8:04 pm 
Newbie

Joined: Wed Dec 15, 2010 7:16 pm
Posts: 1
Which is the best way to work with database connection?

a) By doing a JNDI Look up as shown below
<persistence-unit name="MyPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/MyDataSource</jta-data-source>

<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false"/>
</persistence-unit>


OR


b) By using a Third party connection pool

<persistence-unit name="MyPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>

<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:abc"/>
<property name="hibernate.connection.username" value="def"/>
<property name="hibernate.connection.password" value=""/>

<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>
</properties>

</persistence-unit>

In a light weight development environment it is easy to test and develop using a third party connection pool provider like c3p0 rather than doing a jndi look up as you need a jndi provider running for a JNDI lookup. But I also saw a suggestion in hibernate documentation saying we should use an application server provided JNDI datassource. So does this mean we can use a third party connection pool provider like c3p0 provider for development purpose and while deploying into production or UAT we can change the configuration to do a JNDI Look up and there by using the application server provided datasource say by just adding the following configuration.

<jta-data-source>java:/MyDataSource</jta-data-source>

Is this a good approach?


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

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.