Oracle数据源连接池不能与Spring和JDBCTemplate一起使用 [英] Oracle data source connection pooling not working used with Spring and JDBCTemplate

查看:116
本文介绍了Oracle数据源连接池不能与Spring和JDBCTemplate一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:即使使用连接池,也有很多与数据库建立的活动未关闭物理连接。有人可以告诉我为什么会这样吗?

Question: Lot of active unclosed physical connections with database even with connection pooling. Can someone tell me why is it so?

我使用 oracle.jdbc.pool.OracleDataSource 。然而,似乎物理连接在使用后没有关闭。
我想,既然它是连接池,连接将从池中重用,所以不会有很多物理连接,
但这不是现在发生的事情!

I configured the connection pool settings using oracle.jdbc.pool.OracleDataSource. However it seems the physical connections are not getting closed after use. I thought, Since it is connection pooling, the connections will be reused from the pool, so so many physical connections will not be made, but thats not what is happening now!

从应用程序[不是来自plsql开发人员或任何此类客户端工具]生成的数据库中有100多个活动物理连接,
因为它在尝试时启动TNS错误在数据库上执行写操作,
其中,即使有大量活动连接,读取操作也很好。

There are 100+ active physical connections in the database generating from the application [not from plsql developer or any such client tools], due to which it kicks off TNS error while trying to do write operations on database, where as read operations are fine even with large number of active connections.

这是Spring配置,

Here is the Spring configuration,

<bean id="oracleDataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close"
                                p:URL="${url}"
                                p:user="${username}"
                                p:password="${password}"
                                p:connectionCachingEnabled="true">
                                <property name="connectionProperties">
                                   <props merge="default">
                                      <prop key="AutoCommit">false</prop>
                                   </props>
                                </property>
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
                                p:dataSource-ref="oracleDataSource" />

<bean id="transactionManager"
                                class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
                                p:dataSource-ref="oracleDataSource">
</bean>

返回100多个活动连接的SQL是,

The SQL that returned the 100+ active connections is ,

select username, terminal,schemaname, osuser,program from v$session where username = 'grduser'


推荐答案

您应该配置连接缓存,隐式连接缓存的最大连接的默认值是为数据库配置的最大数据库会话数。

You should configure connection cache, the default value of max connections for implicit connection cache is the max number of database sessions configured for the database.

这篇关于Oracle数据源连接池不能与Spring和JDBCTemplate一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆