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