Posts Tagged “Java”

As I found out within the last days it isn’t that easy to find informations about how to connect Java through JDBC with a DB2 Database remotely. So if you should come into these troubles as well, take care of this:

As DB2 driver you need to use which is located in the same file ( as the default driver( which is “promoted” on most sites. The problem with these two drivers is that they’re not able to work with the other kind of connection. So If you inserted the net driver you can’t create local connections and vice versa. If you want to be flexible you need to use as driver which is capable to handle both types of connections. The driver can be found within the db2jcc.jar file, which should be located in the same place as At least for me it was further needed to provide a license in order to establish a remote connection, to achieve this add a file called db2jcc_license_cu.jar or maybe some file which is similiar named to your Classpath.

Connection string: After some search I found the DB2 page where the remote connection string was described. The string has follow this scheme for remote connections:jdbc:db2://SERVERNAME:PORT/DATABASE Not sure if can leave the DATABASE and run later a Connect to DATABASE Query. At least my quick tries resulted each time with an Exception caused by wrong connection strings.
If you don’t know on which port your DB2 Instance is running take a look at your /etc/services and look for the corresponding line

Now you should be ready to successfully open a remote Connection.

Tags: none

Tags: DB2, Java, JDBC, remote Connection

Comments No Comments »

Bad Behavior has blocked 18243 access attempts in the last 7 days.