Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Location
    Pinellas County Florida
    Posts
    20

    Unanswered: db2jcc.jar Type4 driver and WAS 4.0

    Does anybody know if it is possible to set up a DB2ConnectionPoolDataSource using the Type 4 JDBC driver in db2jcc.jar under WebSphere AppServer 4.0 (WAS 4.0)?

    I try to set it up and I get a NoClassDefFoundError for org/ietf/jgss/GSSCredential.

    I don't want to install the v8.1 client on my Aix WAS server, just the jar files and any necessary .so files. My WAS 4.0 WAS database is 7.2 so I have the 7.2 client installed there. I don't know if it is possible to install both clients on the same server.

    Also, I want to connect to both a UDB Version 8.1 database and a UDB Version 7.2 database. I think this is possible after one converts the 7.2 database to use DRDA protocol.

    Am I on the right track?

  2. #2
    Join Date
    Sep 2002
    Location
    Pinellas County Florida
    Posts
    20

    Re: db2jcc.jar Type4 driver and WAS 4.0

    I am going to go ahead and answer my own question now that I have this working.

    Is it possible to set up a DB2ConnectionPoolDataSource using the Type 4 JDBC driver in db2jcc.jar under WebSphere AppServer 4.0 (WAS 4.0)?
    Yes. First I proved that I could connect to the database in question outside of WAS 4.0. I did this by running the following simple java program. This program is based on some simple examples found on various IBM web pages. It contains 3 different methods for connecting:
    [list=1][*] JDBC 1.0 DriverManager method[*] DB2SimpleDataSource method[*] DB2ConnectionPoolDataSource method.[/list=1]
    Code:
    import java.sql.*;              // JDBC base
    import javax.naming.*;      // JNDI Naming Services
    import javax.sql.*;            // JDBC 2.0 standard extension APIs
    import com.ibm.db2.jcc.*; // DB2 implementation of JDBC 2.0
                                          // standard extension APIs
    
    public class DBDSType4
    {
      public DBDSType4() { }
    
    
      public static void main( String args[] )
      {
        // Check arguments
        if ( args.length < 6 )
        {
          System.out.println( "Usage: java DBConnType4 <database name>"
                                    + " <userid> <password> <server hostname> "
                                    + " <DB2 Instance Port> <Description>" );
          return;
        }
    
        Connection conn = null;
        PooledConnection pc = null;
        try
        {
          String sDBname     = args[0];
          String sUserid        = args[1];
          String sPassword    = args[2];
          String sServer        = args[3];
          String sPortNumber = args[4];
          String sDescription  = args[5];
          String sURL = "jdbc:db2://" + sServer + ":" + sPortNumber + "/" + sDBname;
    
          // Register driver for Type 2, JDBC 1.0
    //      Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
    //      Connection conn = DriverManager.getConnection( sURL, sUserid, sPassword );
          // Type 4, ConnectionPoolDataSource
          DB2ConnectionPoolDataSource db2ds = new com.ibm.db2.jcc.DB2ConnectionPoolDataSource();
          // Type 4, SimpleDataSource
    //      DB2SimpleDataSource db2ds = new com.ibm.db2.jcc.DB2SimpleDataSource();
    
          db2ds.setDatabaseName( sDBname );
          db2ds.setServerName( sServer );
          db2ds.setDriverType( 4 );
          db2ds.setPortNumber( Integer.parseInt( sPortNumber ) );
          db2ds.setDescription( sDescription );
          db2ds.setUser( sUserid);
          db2ds.setPassword( sPassword );
    
    //      Context ctx=new InitialContext();
    //      ctx.bind("jdbc/EcomAix2CHIPFIND",db2ds);
    
          // Type 4, ConnectionPoolDataSource
          pc = db2ds.getPooledConnection();
          conn = pc.getConnection();
          // Type 4, SimpleDataSource
    //      conn = db2ds.getConnection();
    
          System.out.println(
            "Successful connection to '" + sDBname + "' using JDBC Type 4 driver" );
        }
        catch ( Exception ex )
        {
          ex.printStackTrace();
        }
        finally
        {
          if ( null != conn ){ try{ conn.close(); }catch( SQLException ignore ){ } }
          if ( null != pc   ){ try{   pc.close(); }catch( SQLException ignore ){ } }
        }
      }
    
    }
    Here is a sample command line (all on one line, of course):
    Code:
    java -cp /home/db2inst1/db2jcc.jar:/usr/WebSphere/AppServer/lib/j2ee.jar:. \
       DBDSType4 MYDBNAME myuser password myserver 50000 "Type 4 JDBC to MYDBNAME on myserver"
    BTW, the reference to j2ee.jar in the classpath is only necessary for JDK versions prior to 1.4 (WAS 4.0 uses only 1.3). Starting with JDK 1.4, the optional javax.sql.* package is a part of J2SE.

    Here is a link to the IBM web page from which I gleaned this sample program:

    DB2 UDB Connectivity Cheat Sheets: Part 4:Connecting to a DB2 UDB database (any platform) using the IBM DB2 UDB type 4 driver (Universal Driver)


    This program proved that I could connect to my target database using the Type 4 Universal Driver without relying on or installing a local DB2 client, without cataloging the target database at all. It makes a Java connection using DRDA protocol directly to the target database.

    The Universal JDBC Driver requires the following properties to be set:
    [list=1][*]databaseName (should be the name of the database on the remote server, there is no need to catalog a local alias for it).[*]serverName (this can be the server name, or an IP address)[*]portNumber (the default is 446, but we use 50000 because that is the default used by the DB2 Client Configuration Assistant)[*]driverType (this is very important!! If you want Type 4 connectivity, you have to set this property to 4. Default is 2)[*]user[*]password[/list=1]

    But when I tried to invoke this same JDBC driver by setting up a JDBC provider and DataSource using WAS 4.0's administration console, I still got the following error:

    RemoteException: nested exception is java.lang.NoClassDefFoundError for org/ietf/jgss/GSSCredential.

    To solve this, I downloaded jgss.jar from here. I have no idea what this organization is, I just did a google search for jgss.jar and this was the first place I found it.

    I then put jgss.jar in <WAS_HOME>/lib directory, then stopped and restarted WAS. After I started the administration console again, I opened up my Type4 DataSource and clicked the "Test Connection" button. This time it worked.

    Perhaps this jar should go in the <WAS_HOME>/lib/ext directory, but it has to be available when WAS starts up so the bootclassloader can see it. The problem is that this file is likely to get blown away the next time we upgrade WAS.

    I suppose the correct way to do this is to add jgss.jar to its own directory (something like <WAS_HOME>/lib/jgss) and then add this path to the ws.ext.dirs property. The thing is, I don't know where or how to set this property and I'm too lazy to go looking.

    I don't want to install the v8.1 client on my Aix WAS server, just the jar files and any necessary .so files. My WAS 4.0 WAS database is 7.2 so I have the 7.2 client installed there. I don't know if it is possible to install both clients on the same server.
    It was not necessary to install the v8.1 client on the Aix WAS server. Nor were any .so files required. Nor was I required to install any special stored procedures. Nor was any license jar file required. These things are mentioned in the various installation FAQs from IBM, but they are only necessary for other OSes. Using the Type 4 Universal Driver from one RS6000 (running Aix 5.1) to another was really a piece of cake.

    Also, I want to connect to both a UDB Version 8.1 database and a UDB Version 7.2 database. I think this is possible after one converts the 7.2 database to use DRDA protocol.

    Am I on the right track?
    Yes, I am on the right track. I have to modify our web applications to use the datasource I just created in order to prove that they will work with a v8.1 database. Then I can convert our 7.2 database to use DRDA. However, I think I will just migrate our 7.2 database to 8.1 rather than simply convert it to using DRDA. For one thing, one cannot fully exploit the Type 4 Universal Driver on a 7.2 database. There are certain features that require an upgraded DB engine.

    But that's a task for another day.

    Would I sound bitter if I noted that IBM WebSphere Support was of no help solving this problem (as usual)? I know they try hard and they charge a lot, but it's so rare that they come through with an answer. I am very satisfied with the answers I get from the DB2 and Aix support teams, but WebSphere support is still not up to par.
    Last edited by milkchaser; 03-15-04 at 20:33.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •