Bug #14830 | JDBC inefficiency in the jdk1.5 envirment | ||
---|---|---|---|
Submitted: | 10 Nov 2005 14:39 | Modified: | 17 Nov 2005 4:47 |
Reporter: | cheney s | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S1 (Critical) |
Version: | 3.1.11 | OS: | Windows (Windows XP) |
Assigned to: | CPU Architecture: | Any |
[10 Nov 2005 14:39]
cheney s
[16 Nov 2005 16:47]
Mark Matthews
I can't repeat this, except when I can't reach a DNS server. The first connection does take longer than subsequent ones, however I can attribute this to class loading and the JIT doing some compilation, but it's not orders of magnitude slower as your situation seems to be. What operating system is this? What happens if you use IP addresses as well as set "--skip-name-resolve" on the server? Does the problem go away? If so, it's a DNS issue on your end.
[17 Nov 2005 4:47]
cheney s
Thank you very much. When connecting localhost,it's very fast in both 1.4 and 1.5. But connect to non-localhost, is't fast in 1.4 also, and have efficiency issue in 1.5. See my results blow,any help would be great. jdk1.4 Reslut: 672(ms) 750(ms) 828(ms) jdk1.5 Reslut: 5038(ms) 9624(ms) 14211(ms) --- test code --- public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } java.sql.Connection conn = null; try { long begin = System.currentTimeMillis(); conn = java.sql.DriverManager.getConnection("jdbc:mysql://192.168.35.194/test"); conn.close(); System.out.println((System.currentTimeMillis()-begin)+ "(ms)"); conn = java.sql.DriverManager.getConnection("jdbc:mysql://192.168.35.194/test"); conn.close(); System.out.println((System.currentTimeMillis()-begin) + "(ms)"); conn = java.sql.DriverManager.getConnection("jdbc:mysql://192.168.35.194/test"); conn.close(); System.out.println((System.currentTimeMillis()-begin) + "(ms)"); } catch (java.sql.SQLException e) { e.printStackTrace(); } }