Oracle getConnection运行缓慢 [英] Oracle getConnection slow

查看:472
本文介绍了Oracle getConnection运行缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java项目中,我使用的是ojdbc6 jar

In a Java project, I am using an ojdbc6 jar

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.1.0</version>
        <scope>compile</scope>
    </dependenc>

我运行的第一天,dataSource.getConnection()很快。第二次通常没关系。接下来的几次大约需要45秒。之后,需要几分钟。一旦我有一个给定应用程序运行的FIRST连接,我得到的任何新连接都非常快。这个延迟只是获得给定运行的第一个连接。

The first time for a day I run, dataSource.getConnection() is fast. Second time is usually okay. The next few times take around 45 seconds. After that, it takes multiple minutes. Once I have the FIRST connection of a given application run, any new connections I get are very very fast. This delay is only getting the FIRST connection for a given run.

是什么让我的第一个连接变得这么慢?

What is making getting my first connection so slow?

我正在观看netstat并且在成功运行后看不到任何连接。尝试了几个不同的连接池( DBCP,C3PO ),没有运气。通过源代码进行调试,延迟是 org.springframework.jdbc.datasource.DataSourceUtils

I am watching netstat and don't see any connection hanging after a successful run. Have tried several different connection pools (DBCP, C3PO) with no luck. Debugging through source code, the delay is 100% on the line of org.springframework.jdbc.datasource.DataSourceUtils:

Connection con = dataSource.getConnection();

任何想法?

编辑了更多详细信息

1)我正在使用连接池(DBCP或C3PO)来保存连接以备将来使用。当我谈到获得新连接时,我的意思是在第一个连接正在使用时......我需要转到数据库并获得新连接。当然,我可以一遍又一遍地从连接池返回并获得相同的连接。但同时获得第二个也很快。

1) I am using a connection pool (DBCP or C3PO) which saves connections for future use. When I talk about getting a new connection, I mean while the first connection is in use.. I need to go to the DB and get a NEW connection. Of course I can return and get my same connection from the connection pool over and over again. But getting a second at the same time is also fast.

2)我不知道我的数据库允许我登录多少个连接。知道这个属性在oracle中的位置吗?

2) I do not know how many connections my DB lets me be logged in with. Any idea where this property is in oracle?

推荐答案

是由于java使用/ dev / random而不是/ dev / urandom来与数据库建立一个ssh连接....切换到/ dev / urandom修复了这个

Was due to java using /dev/random instead of /dev/urandom to make a ssh connection with the database.... switching to /dev/urandom fixed this

这篇关于Oracle getConnection运行缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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