My problem occurs when I specify a serverName to a DB2DataSource when registering a DB2DataSource with JNDI. The registration completes, but subsequent calls to DB2DataSource.getConnection() fail. If I don't specify a serverName, the connections work - if I do specify the serverName, the connections fail. I tested the same scenario with MySQL and its MysqlDataSource implementation and it worked perfectly. I'm totally confused. Why would supplying a serverName cause errors? Here's the stacktrace: COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0616E Error opening socket. SQLSTATE=08S01 at java.lang.Throwable.<init>(Throwable.java:96) at java.lang.Exception.<init>(Exception.java:44) at java.sql.SQLException.<init>(SQLException.java:45) at COM.ibm.db2.jdbc.DB2Exception.<init>(DB2Exception.java:93) at COM.ibm.db2.jdbc.DB2Exception.<init>(DB2Exception.java:111) at COM.ibm.db2.jdbc.net.SQLExceptionGenerator.socketException(SQLExceptionGenerator.java:574) at COM.ibm.db2.jdbc.net.DB2Connection.create(DB2Connection.java:244) at COM.ibm.db2.jdbc.net.DB2Connection.<init>(DB2Connection.java:184) at COM.ibm.db2.jdbc.net.DB2ReusableConnection.<init>(DB2ReusableConnection.java:69) at COM.ibm.db2.jdbc.DB2PooledConnection.getConnection(DB2PooledConnection.java:198) at COM.ibm.db2.jdbc.DB2DataSource.getConnection(DB2DataSource.java:116) at COM.ibm.db2.jdbc.DB2DataSource.getConnection(DB2DataSource.java:91) at DataSourceRegistrationTool.connect(DataSourceRegistrationTool.java:39) at DataSourceRegistrationTool.main(DataSourceRegistrationTool.java:68) Here's my code: *********** Context ctx = null; Hashtable env = null; COM.ibm.db2.jdbc.DB2DataSource ds = null; env = new Hashtable(); env.put( Context.INITIAL_CONTEXT_FACTORY, "COM.ibm.db2.jndi.DB2InitialContextFactory" ); ctx = new InitialContext( env ); ds = new COM.ibm.db2.jdbc.DB2DataSource(); //ds.setServerName( "myserver.com" ); //ds.setServerName( "127.0.0.7" ); //ds.setServerName( "localhost" ); ds.setDatabaseName( "mwsales" ); ds.setUser( "username" ); ds.setPassword( "password" ); ds.setPortNumber( 50000 ); ctx.unbind( "/tmp/jdbc/mwsales" ); ctx.bind( "/tmp/jdbc/mwsales", ds ); ctx.close(); System.out.println( "Registered: /tmp/jdbc/mwsales" ); *** this works for mysql, but failes for db2 when a host is provided. DataSource ds2 = (DataSource)ctx.lookup("/tmp/jdbc/mwsales"); Connection con = ds2.getConnection(); Any help would be greatly appreciated!
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.