DriverManager.getConnection() : very strange behavior
843859Sep 17 2008 — edited Dec 16 2009I am currently developping a SWING application generated with NetBeans 6.1 which connects to either a MySQL DB or a PostgresSQL DB, both hosted by a Linux server.
The application runs just FINE on Solaris/SPARC, Solaris/x86 and Linux/x86.
The problems come with Windows/x86 : the call to DriverManager.getConnection() just stalls, no error, no timeout, no exception.
After investigating a little bit more I found some "funny" behaviors that I submit here for comments:
The drivers loaded since the main() function using:
Class.forName("com.mysql.jdbc.Driver");
Class.forName("org.postgresql.Driver");
The application gets connected to the DB with the following connection code :
try {
DriverManager.getConnection( "jdbc:mysql://192.168.2.3:3306/ZEDB", "user", "pwd" );
DriverManager.getConnection( "jdbc:postgresql://192.168.2.3:5432/ZEDB", "user", "pwd" );
}
catch (Exception x) { [...] }
And the results are (tried with JDK 5u16 and JDK 6u7)
- On Windows :
-> OK in a console Application
-> OK in a Swing/AWT Application if the connection code is in the main function
-> NOK in a Swing/AWT Application if the connection code is placed anywhere within a SWING Form AND server is remote,
-> Last case if OK if server is "localhost" (tested only with MySQL -for Windows- however ).
- On Linux or Solaris : OK on any case
Any idea ?
- Dom