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?
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With