Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle getConnection slow

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?

like image 968
bwawok Avatar asked Mar 31 '11 16:03

bwawok


People also ask

Why is my Oracle database slow?

The most common causes of slow performance are as follows: Excessive round-trips from the application server to the database. Ideally, each UI operation should require exactly one round-trip to the database. Sometimes, the framework will require additional round-trips to retrieve and make session data persistent.

Why is Tnsping so slow?

If you observe that TNSPING is returning very late/slow, and application connection is also very slow, there are a couple of things that you can check. First thing is to use network speed. You can use OS command “ping” to check if network is stable and response is fast enough.

Is ojdbc8 compatible with Oracle 19c?

For Oracle 19c, you can use either ojdbc8. jar or ojdbc10. jar. OJDBC10 is compiled with Java 10 and will not work unless you're running Bamboo 8 with Java 11.

Does Oracle use TCP?

The TCP/IP with Secure Sockets Layer (SSL) protocol enables an Oracle application on a client to communicate with remote databases through TCP/IP and SSL. Oracle Advanced Security is required to use TCP/IP with SSL.


1 Answers

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

like image 137
bwawok Avatar answered Sep 28 '22 07:09

bwawok