DriverManager.getConnection is too slow in linux
Posted by: 오종현 남
Date: October 15, 2015 02:31AM

Hello, I'm Jack and using MySQL for my study.

i'd like to ask a question i found today.

before get started,

my environment like this.

MySQL server
version : 5.2.8-MariaDB
os: Windows ??

Java Application Server
os : linux 2.6.32-504.e16.x86_64
connector version : 5.1.36
jdk ver : 1.7.72

so the problem is,

it takes more than 4seconds on this statement to get connection.


but the strange thing is, if i run this at windows machine,

it takes only 200ms.

while this hanging, i capture thead dump and found out that socket read is holding.

i'd like to reduce this 'making connection time' and understand why this happens.

java.lang.Thread.State: RUNNABLE
at Method)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(
- locked <0x000000058203d870> (a com.mysql.jdbc.util.ReadAheadInputStream)
at com.mysql.jdbc.MysqlIO.readFully(
at com.mysql.jdbc.MysqlIO.readPacket(
at com.mysql.jdbc.MysqlIO.doHandshake(
at com.mysql.jdbc.ConnectionImpl.coreConnect(
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(
at com.mysql.jdbc.ConnectionImpl.createNewIO(
- locked <0x0000000581da3a68> (a com.mysql.jdbc.JDBC4Connection)
at com.mysql.jdbc.ConnectionImpl.<init>(
at com.mysql.jdbc.JDBC4Connection.<init>(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at com.mysql.jdbc.Util.handleNewInstance(
at com.mysql.jdbc.ConnectionImpl.getInstance(
at com.mysql.jdbc.NonRegisteringDriver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at jTest.MySQLDBConnector.initializeDataBase(
at jTest.JavaTest.main(

Thanks for your help in advance.

Options: ReplyQuote

Written By
DriverManager.getConnection is too slow in linux
October 15, 2015 02:31AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.