Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access to DB2 UDB thru JDBC

 
Bala Ramachandran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need some help in figuring out the JDBC access to DB2.
I am trying to acces a DB2 UDB database server from a stand-alone Jaba application, thru JDBC using "COM.ibm.db2.jdbc.net.DB2Driver". I get the following exception:
COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0616E Error opening socket. SQLSTATE=08S01.
When I try it with the driver "CON.ibm.db2.jdbc.app.DB2Driver", I get the exception:
java.sql.SQLException: No suitable driver
I have installed the DB2 client on my machine and I have the db2java.zip included in my classpath.
Actually I need to use this is a JSp/servlet. But I thought I would first test it in a simple Java program.
Can anyone help me ?
Thank You
Bala.
 
Nathanael Ulrick
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To use the net driver, you need to have db2jstrt running on the host machine. The default port then would be 6789, although you can specify a different port. I've read somewhere that you'd need db2jstrt running on the client with the same port as well -- I doubt this is the case, but try it if you get stuck. Also, the copy of db2java.zip has to be the same as the one on the server.
If you use the app driver, the client config assistant needs to know about the server, and the port that you'd use won't be the same as the above (usually 50000, if you've only got one instance of db2.)
By the way, the JDBC drivers on 6 and 7 are buggy, so get the latest fixpack (and don't forget to keep db2java.zip in sync.)
You might find a 3rd party driver, eg from HiT Software much simpler to use.
 
Bala Ramachandran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nathanael Ulrick:
To use the net driver, you need to have db2jstrt running on the host machine. The default port then would be 6789, although you can specify a different port. I've read somewhere that you'd need db2jstrt running on the client with the same port as well -- I doubt this is the case, but try it if you get stuck. Also, the copy of db2java.zip has to be the same as the one on the server.
If you use the app driver, the client config assistant needs to know about the server, and the port that you'd use won't be the same as the above (usually 50000, if you've only got one instance of db2.)
By the way, the JDBC drivers on 6 and 7 are buggy, so get the latest fixpack (and don't forget to keep db2java.zip in sync.)
You might find a 3rd party driver, eg from HiT Software much simpler to use.

Hi,
Thanks for the reply. I have the db2java.zip in the Sun machine (which is the client). Does it mean I need the db2java.zip in the database server too ? If so, what version should I use. The database server is a IBM SP2 running on AIX. Will the version of db2java.zip be compatible with the db2java.zip in the Sun machine ?
Also, in the connection URL should I use 50000 or 6789 ?
I appreciate your help.
Thanks
Bala.
 
Nathanael Ulrick
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you'll be running a servlet, the net driver would probably be the most appropriate....
db2java.zip should already be on the server, in sqllib/java
I would copy this file to the client. It should work even if the two machines are different types. Include this file in your classpath.
Also, you have to execute db2jstrt on the server. If you do not specify any arguments, this will open port 6789.
Connect with the net driver using a url which should look something like this:
jdbc:db2:yourserver:6789/yourschema
 
Bala Ramachandran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nathanael Ulrick:
Since you'll be running a servlet, the net driver would probably be the most appropriate....
db2java.zip should already be on the server, in sqllib/java
I would copy this file to the client. It should work even if the two machines are different types. Include this file in your classpath.
Also, you have to execute db2jstrt on the server. If you do not specify any arguments, this will open port 6789.
Connect with the net driver using a url which should look something like this:
jdbc:db2:yourserver:6789/yourschema

Hi,
Thanks a lot for your help. I confirmed that the server has db2java.zip and then I ran db2jstrt on the server. I was able to get past the problem.
Thanks
Bala.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic