You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Filipe David Manana <fd...@ieee.org> on 2007/12/11 22:56:18 UTC

Struts 2 + Spring 2 + JPA + Oracle + Connection Caching/Pooling

Hi all,

I want to create a web app with Struts 2 that is Oracle database driven.
Integrating Struts 2 + Spring 2 + JPA (as described in
http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html), how do I
configure Oracle database Connection Caching (pooling)?

Oracle's JDBC driver provided in the Oracle Instant Client package has a
Connection Cache implementation class (
oracle.jdbc.pool.OracleConnectionCacheImpl) which I can use in my JDBC code.
I have been unsuccessfully googling for how to enable this Connection
Caching feature with Struts 2 + Spring 2 + JPA.

Has anybody done it before?

--
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

Re: Struts 2 + Spring 2 + JPA + Oracle + Connection Caching/Pooling

Posted by "Alberto A. Flores" <aa...@gmail.com>.
Database Connection Pooling is typically handled (already) by the 
container. You can get your datasource from this connection pooling 
using JNDI. Spring has a way of doing this nicely using the 
JndiObjectFactoryBean. Each container has a different way to configure 
this JNDI configuration, so you need to read their documentation and 
play with it.

Now, ORMs typically do their own connection caching (e.g. Hibernate), 
but in my understanding, the prefer way of doing connection pooling is 
via JNDI, so as to use the JEE specification appropriately. In the 
Struts sample, I think TopLink (instead of Hibernate) is used. 
Alternatively, the commons DBCP does connection pooling for you as well 
(if you don't want to use JNDI and rely on the container for pooling). 
It's a matter of creating a new <bean id="datasource" ...> and let 
Spring inject the one you want.

Your choice, of course.

BTW, this is hardly a Struts question :)

Filipe David Manana wrote:
> Hi all,
> 
> I want to create a web app with Struts 2 that is Oracle database driven.
> Integrating Struts 2 + Spring 2 + JPA (as described in
> http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html), how do I
> configure Oracle database Connection Caching (pooling)?
> 
> Oracle's JDBC driver provided in the Oracle Instant Client package has a
> Connection Cache implementation class (
> oracle.jdbc.pool.OracleConnectionCacheImpl) which I can use in my JDBC code.
> I have been unsuccessfully googling for how to enable this Connection
> Caching feature with Struts 2 + Spring 2 + JPA.
> 
> Has anybody done it before?
> 
> --
> Filipe David Manana,
> fdmanana@ieee.org
> 
> Obvious facts are like secrets to those not trained to see them.
> 

-- 

Alberto A. Flores
http://www.linkedin.com/in/aflores



Re: Struts 2 + Spring 2 + JPA + Oracle + Connection Caching/Pooling

Posted by Musachy Barroso <mu...@gmail.com>.
I have no idea how to do that, but it isn't specific to Struts or JPA.
Spring documentation would be the best place to look that up I guess.

musachy

On Dec 11, 2007 4:56 PM, Filipe David Manana <fd...@ieee.org> wrote:
> Hi all,
>
> I want to create a web app with Struts 2 that is Oracle database driven.
> Integrating Struts 2 + Spring 2 + JPA (as described in
> http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html), how do I
> configure Oracle database Connection Caching (pooling)?
>
> Oracle's JDBC driver provided in the Oracle Instant Client package has a
> Connection Cache implementation class (
> oracle.jdbc.pool.OracleConnectionCacheImpl) which I can use in my JDBC code.
> I have been unsuccessfully googling for how to enable this Connection
> Caching feature with Struts 2 + Spring 2 + JPA.
>
> Has anybody done it before?
>
> --
> Filipe David Manana,
> fdmanana@ieee.org
>
> Obvious facts are like secrets to those not trained to see them.
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 + Spring 2 + JPA + Oracle + Connection Caching/Pooling

Posted by Filipe David Manana <fd...@ieee.org>.
Thanks! :)

By the way, I have "bad" news...
The OracleConnectionCachingImpl class is actually deprecated. Use
OracleConnectionCacheManager with OracleDataSource instead.
Take a look at:

oracle JDBC reference:
http://download-west.oracle.com/docs/cd/B12037_01/java.101/b10979/toc.htm

oracle JDBC resources:
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/oracle10g/conncache/Readme.html

Found it 2 days ago, thanks to an Eclipse warning :)
How to port this to Spring/Struts2 I have no idea... I am actually doing my
Model layer using directly jdbc.

cheers


On 12/18/07, kenk <ke...@earthlink.net> wrote:
>
>
> Filipe,
>
> Funny, I was looking for the same information.  Here's the Spring
> configuration I'm moving forward with to use the Oracle connection
> pooling:
>
> <!-- Database connection using the Oracle connection pool -->
> <bean id="dataSource" class="oracle.jdbc.pool.OracleConnectionCacheImpl" >
>         <property name="connectionPoolDataSource" >
>                 <bean class="
> oracle.jdbc.pool.OracleConnectionPoolDataSource" >
>                         <property name="URL"                    value="
> jdbc:oracle:thin:@devlxdb02:1522:xxxxxx"
> />
>                         <property name="user"           value="xxxxxx" />
>                         <property name="password"   value="xxxxxx" />
>                 </bean>
>         </property>
>         <property name="maxLimit"       value="10" />
>         <property name="minLimit"       value="2" />
> </bean>
>
> Seems to work for now.  There is probably a less verbose way to do this.
> And yes I agree this isn't a Struts question, but I hope it helps.
>
> thx,
> Ken K
> --
> View this message in context:
> http://www.nabble.com/Struts-2-%2B-Spring-2-%2B-JPA-%2B-Oracle-%2B-Connection-Caching-Pooling-tp14284397p14398750.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

Re: Struts 2 + Spring 2 + JPA + Oracle + Connection Caching/Pooling

Posted by kenk <ke...@earthlink.net>.
Filipe,

Funny, I was looking for the same information.  Here's the Spring
configuration I'm moving forward with to use the Oracle connection pooling:

<!-- Database connection using the Oracle connection pool -->
<bean id="dataSource" class="oracle.jdbc.pool.OracleConnectionCacheImpl" >
	<property name="connectionPoolDataSource" >
		<bean class="oracle.jdbc.pool.OracleConnectionPoolDataSource" >
			<property name="URL" 			value="jdbc:oracle:thin:@devlxdb02:1522:xxxxxx"
/>
			<property name="user"		value="xxxxxx" />
			<property name="password"   value="xxxxxx" />
		</bean>
	</property>
	<property name="maxLimit"	value="10" />
	<property name="minLimit"	value="2" />
</bean>

Seems to work for now.  There is probably a less verbose way to do this. 
And yes I agree this isn't a Struts question, but I hope it helps.

thx,
Ken K
-- 
View this message in context: http://www.nabble.com/Struts-2-%2B-Spring-2-%2B-JPA-%2B-Oracle-%2B-Connection-Caching-Pooling-tp14284397p14398750.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org