HP3000-L Archives

August 2006, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Chris Thompson <[log in to unmask]>
Reply To:
Chris Thompson <[log in to unmask]>
Date:
Fri, 11 Aug 2006 01:04:23 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (184 lines)
Jeff and Charles,

The following DB2 JDBC driver information from my Certified DB2 
Developer notes may be helpful.

DB2 JDBC drivers are categorized as legacy CLI-based drivers and
new universal JDBC drivers.

The legacy CLI-based JDBC driver is built on top of the native DB2 CLI. 
There are two implementation classes. The first is a JDBC Type 2 driver, 
also known as an app driver. It is implemented by the class
com.ibm.db2.jdbc.app.DB2Driver. This driver will be deprecated in DB2 
UDB Version 8.2.

The other implementation is a JDBC Type 3 driver, also known as the 
applet or net driver.  The net driver is deprecated in DB2 V8; migration 
to a Type 4 driver is recommended.

To use the app driver, a DB2 client must be installed on the client 
machine where the JDBC programs are to be executed. All the JDBC calls 
are translated into DB2 CLI calls.

The DB2 JDBC Type 3 driver also maps JDBC calls to DB2 CLI. With this
driver, a DB2 client is not required on the client machine. However, a 
JDBC
listener (or JDBC daemon) is needed. You can only use the
JDBC Type 3 Driver to create Java applets.

Fixpak 2 of DB2 V8 introduced the DB2 Universal JDBC driver. It is 
called a universal driver because it uses the Distributed Relational 
Database
Architecture (DRDA) protocol that is common to all DB2 family databases. 
This driver enables direct Java connectivity to DB2 servers using a Type 
4 driver architecture. The driver also has two implementation classes, 
called the Java Common Client (JCC) Type 2 driver and JCC Type 4 driver. 
Thus, you can use this driver for both applets and applications. In 
fact, it is the recommended driver for both. The implementation class 
name is com.ibm.db2.jcc.DB2Driver.

Although I am unable to find confirming information, I am 99% sure that 
the DB2 type 4 JDBC driver requires Java 1.4 or better, so I would 
concur with Charles' opinion but caution against using the older 
drivers.

................................
Jeff,

if you're not already doing so, try adding the default port number 
(50000) to the driver call.
eg.

String DB2_URL =
"jdbc:db2://127.0.0.1:50000/database:user=user;password=pwd;";

Also here's some simple code, not mine, that usually works.

Try this (watch for wrapped lines):

import java.lang.*;
import java.sql.*;

public class MyJccTest
{
    public static void main (String args[]) throws Exception
    {
    if (args.length !=3)
       {
       System.out.println("required: <databasename> <userid> 
<password>");
       System.exit(0);
       }

    String url = "jdbc:db2://localhost:50000/" + args[0];
    System.out.println("  Connect to '" + args[0]+ "' database using JCC 
driver and type 4 connectivity." );
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    Connection con = DriverManager.getConnection( url, args[1], args[2]);
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("Select '1',user,current sqlid from 
sy
sibm.sysdummy1");
    while (rs.next())
    System.out.println(rs.getString(1) + ' ' + rs.getString(2) + ' ' + 
rs.getString(3));
    stmt.close();
    rs.close();
    con.close();
    }
}



Hope this helps.

Chris Thompson
[log in to unmask]
The Internet agency, UK
Distibutors of the TRAX Cobol debugger and ADBC, the java api for 
Turboimage







In message <[log in to unmask]>, Charles 
Finley <[log in to unmask]> writes
>We use DB2 a lot, however, we have not tried to access it from the HP 3000.
>One thing I would suspect is an incompatibility between the driver and the
>JVM.  Therefore, I would research if the type 4 driver requires a newer JVM
>than jre 1.3. Even if it requires 1.3.1, that could make a difference. If it
>does, you might be sucessfull with the older driver.  The older driver comes
>in a db2java.zip or db2java.jar file as opposed to the 1.4 driver which
>comes in the  db2jcc.jar.
>
>Charles Finley
>619-795-0720
>
>-----Original Message-----
>From: HP-3000 Systems Discussion [mailto:[log in to unmask]]On
>Behalf Of Jeff Stothart
>Sent: Thursday, August 10, 2006 10:21 AM
>To: [log in to unmask]
>Subject: Accessing DB2 with Java?
>
>
>Hello all -
>
>We have a need to access a DB2 database from the hp3000.  We thought we
>could accomplish this with Java, but we have not been successful.
>
>We are on MPE/iX version 7.0.  We downloaded and installed the Java SDK
>1.3 from Jazz.  We believe that the Java environment is set up correctly
>on the hp3000 because we're able to compile and run other (albeit
>simpler) Java programs.  We're using the type 4 JDBC DB2 drivers that we
>got from IBM.  When we run the program on the hp3000 it looks like we
>connect to the JDBC listener on the IBM, but then the listener rejects
>the connection because it says the arguments that we're giving it are
>invalid.  We're passing the target DB name, user id, and password.
>Our speculation is that the listener, for some reason, is not receiving
>the arguments in the format that it expects.  We are not in control of
>opening the socket or communicating with the listener.  All of the
>tcp/ip communications are done by the driver, so we're not exactly sure
>how it's doing it.
>
>There is security on the IBM side (lots of it), but we've worked with
>our internal IBM contact and we don't believe this issue is security
>related.
>
>The interesting thing is that we can move the program that we compiled
>on the hp3000 to either a Windows or HP-UX system and it works.
>
>We know there are 3rd party solutions available but our client would
>rather look at other solutions before going down the 3rd party path.  We
>also think we can accomplish this with Perl and XML Remote Procedure
>Calls (using Frontier::RPC, XML::Parser, expat XML parser).  We have
>tested this method with a simple program using a Windows system as the
>target, and it works.  Downsides to this method are we'd have to write a
>listener/DB2 caller (probably Perl) that would run on the IBM.  Since
>that would be a special, nonstandard background process, we're more at
>risk that if it would have problems, they might not be addressed as
>quickly as problems with the JDBC job.  So we'd really like to get this
>working with Java.
>
>Finally......my question!  Has anyone done this before or does anyone
>have any ideas on what we can try to get this to work?
>
>Thanks!  Jeff
>
>* To join/leave the list, search archives, change list settings, *
>* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
>
>__________ NOD32 1.1701 (20060810) Information __________
>
>This message was checked by NOD32 antivirus system.
>http://www.eset.com
>
>* To join/leave the list, search archives, change list settings, *
>* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2