File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes - Bug? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark " - Bug?" Watch " - Bug?" New topic
Author - Bug?

James Chrystal

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: [IBM][JDBC Driver] CLI0616E Error opening socket. SQLSTATE=08S01
at java.lang.Throwable.<init>(
at java.lang.Exception.<init>(
at java.sql.SQLException.<init>(
at DataSourceRegistrationTool.connect(
at DataSourceRegistrationTool.main(
Here's my code:
Context ctx = null;
Hashtable env = null; ds = null;
env = new Hashtable();
env.put( Context.INITIAL_CONTEXT_FACTORY, "" );
ctx = new InitialContext( env );
ds = new;
//ds.setServerName( "" );
//ds.setServerName( "" );
//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 );
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:
subject: - Bug?
It's not a secret anymore!