• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic