aspose file tools*
The moose likes JDBC and the fly likes COM.ibm.db2.jdbc.DB2DataSource - Bug? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "COM.ibm.db2.jdbc.DB2DataSource - Bug?" Watch "COM.ibm.db2.jdbc.DB2DataSource - Bug?" New topic
Author

COM.ibm.db2.jdbc.DB2DataSource - Bug?

James Chrystal
Greenhorn

Joined: Jul 12, 2001
Posts: 3
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://aspose.com/file-tools
 
subject: COM.ibm.db2.jdbc.DB2DataSource - Bug?