0

I'm using EclipseLink 2.3, of GlassFish 3.1.1, for a simple JPA test with MySQL 5.6.12 and MySQL Connector/J 5.1.25. It works, but in a long running process: about 4-5 minutes. After setting the property 'eclipselink.target-database' into persistence.xml, now it takes about 2 minutes.

Here the fragment of log where you can see the delay:

Running org.consel.jc.jpa.test.JpaTest
...
[EL Config]: 2013-07-12 09:51:27.986--ServerSession(8831815)--Connection(11317592)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
        platform=>MySQLPlatform
        user name=> "root"
        datasource URL=> "jdbc:mysql://localhost:3306/sm"
))
[EL Config]: 2013-07-12 09:53:33.157--ServerSession(8831815)--Connection(15177785)--Thread(Thread[main,5,main])--Connected: jdbc:mysql://localhost:3306/sm
        User: root@localhost
        Database: MySQL  Version: 5.6.12
        Driver: MySQL Connector Java  Version: mysql-connector-java-5.1.25 ( Revision: ${bzr.revision-id} )
[EL Finest]: 2013-07-12 09:53:33.167--ServerSession(8831815)--Connection(15177785)--Thread(Thread[main,5,main])--Connection acquired from connection pool [default].
[EL Finest]: 2013-07-12 09:53:33.167--ServerSession(8831815)--Connection(15177785)--Thread(Thread[main,5,main])--Connection released to connection pool [default].

...

Moreover I use transaction-type="RESOURCE_LOCAL" for manage the transaction via EclipseLink. How can I investigate for search the causes? Thanks

vimterd
  • 191
  • 3
  • 16
  • It looks like the time is during connection initialization, so you might try connecting to the same database from the same machine/environment using straight JDBC and see how long it takes on the first time, before the JPA app is initialized. This will isolate the issue, and from there you can determine if it is a network or driver connection issue. – Chris Jul 12 '13 at 13:24
  • I have followed the tutorial [Connect to MySQL with JDBC driver](http://www.mkyong.com/jdbc/connect-to-oracle-db-via-jdbc-driver-java/) and the cause of the delay is the JDBC driver MySQL Connector/J. I'm testing some versions of its... – vimterd Jul 12 '13 at 16:23
  • I testd all 5.1.x and 5.0.x versions, and always it takes about 2 minutes. Meanwhile with _drizzle-jdbc_ 1.2 and _mariadb-connector-java_ 1.1.1 it takes about 2-3 seconds. I don't know why with official driver I have this problem. – vimterd Jul 15 '13 at 12:52
  • Running GlassFish (embedded version) the DB connection takes about 2 minutes, also with Drizzle and MariaDB. – vimterd Jul 15 '13 at 13:35
  • There are numerous possibilities with the network, machine or server configuration. What was unique about when it was connecting fast? Check out posts here on similar topics such as http://stackoverflow.com/questions/1292856/why-connect-to-mysql-is-so-slow – Chris Jul 16 '13 at 12:33

1 Answers1

0

RESOLVED The problem isn't related of MySQL Connector/J, I solved uninstalling COMODO Firewall that was inactive but caused in any way this delay.

vimterd
  • 191
  • 3
  • 16