Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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>

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?

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();

Any ideas?

Edited For More Details

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) I do not know how many connections my DB lets me be logged in with. Any idea where this property is in oracle?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
394 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...