Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / February 2006

Tip: Looking for answers? Try searching our database.

Connect to DB2 V7 and V8 in Java

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andre.powroznik@nrb.be - 08 Feb 2006 11:00 GMT
Hello,

I am trying to connect, at the same time, to a DB2 V7 database and to a
DB2 V8 database in Java.

Here is some sample code:

import java.sql.DriverManager;

public class DB2V7V8 {
    public static void main(String[] args) throws Exception {
        System.out.println("0");
        Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
        System.out.println("1");
        Class.forName("com.ibm.db2.jcc.DB2Driver");
        System.out.println("2");
        DriverManager.getConnection("jdbc:db2://host1/dbv7","usr","pwd");
        System.out.println("3");
        DriverManager.getConnection("jdbc:db2://host2/dbv8","usr","pwd");
        System.out.println("4");
    }
}

It seems to me that sometimes it works, sometimes it stops at (2),
sometimes at (3)...

Do you know if there is a "standard" way to connect to DB2 V7 and V8
from the same Java application?
Bernd Hohmann - 08 Feb 2006 11:16 GMT
> I am trying to connect, at the same time, to a DB2 V7 database and to a
> DB2 V8 database in Java.

Each db2java.zip delivered with a certain DB2 version (and DB2
fixlevel!) is compatible to this version and fixlevel only. Some
db2java.zip packs are working with more than one DB2 version and
fixlevel but you can't rely on it. Sooner or later you'll get strange
results and error messages.

> Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
> Class.forName("com.ibm.db2.jcc.DB2Driver");

COM.ibm.db2.jdbc & com.ibm.db2.jcc are sharing a lot of classes with the
same name so the result is unpredictable.

I solved the problem by decompiling the whole driver, changing the
packetname from "com.ibm..." to "db2v7fp3.com.ibm..." (for db2 version 7
fixpack 3) and changed the entry point from "jdbc:db2" to
"jdbc:db2v7fp3" and so on.

I didn't found any other solution which works.

Bernd
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.