Urgent! DB2 jdbc connection error

Urgent! DB2 jdbc connection error

Post by Rolf Garsk » Mon, 02 Nov 1998 04:00:00

On 30 Oct 98 20:36:15 GMT, Richard Flores wrote:

:>In developping an internet registration system, we purchased IBM DB2 and
:>Visual Age for JAVA 5.0.  We are currently experiencing problems relating
:>to java applet database access.  We requested help from IBM, however they
:>have not yet responded to our problem (Xo).  We desperately need help!  The
:>only barrier we face now is accessing our database through a java applet
:>(ODBC connection works).  The provided user manuals were of no use, because
:>the information presented was too ambigous for us to understand.  We
:>browsed IBM's website and tried all their suggestions and sample programs
:>however they still did not work.  Brace yourselves, theres a lot of stuff
:>to read but please continue we need help bad!  The following is our html
:><!- Before running the sample, modify the values of the parameters.    ->
:><!- Change myServer to the name of machine your JDBC server is running;->
:><!- change myPort to the port number your JDBC server is listening on; ->
:><!- change myId to the user id you want to use to access the database; ->
:><!- change myPassword to the password corresponding to the above id.   ->
:>    <title>DB2 JDBC Sample Applet </title>
:><h1> <center>DB2 JDBC Sample Applet </center></h1>
:><applet code="DB2Applt.class" width=325 height=275 archive="db2java.zip">
:>        <param name=server value='hal2'>
:>        <param name=port value='3741'>
:>        <param name=userid value='USERID'>
:>        <param name=password value='PASSWORD'>
:>The following is our java applet code.
:>import java.sql.*;
:>import java.awt.*;
:>import java.applet.Applet;
:>public class DB2Applt extends Applet {
:>   static {
:>      try {
:>         // register the driver with DriverManager
:>         // The newInstance() call is needed for the sample to work with
:>         // JDK 1.1.1 on OS/2, where the Class.forName() method does not
:>         // run the static initializer. For other JDKs, the newInstance
:>         // call can be omitted.
:>         Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newInstance();
:>      } catch (Exception e) {
:>         e.printStackTrace();
:>      }
:>   }
:>   Connection con;
:>   public void init() {
:>      resize(150,25);
:>      try {
:>         // get parameter values from the html page
:>         String server = getParameter("server");
:>         String port = getParameter("port");
:>         // construct the URL ( sample is the database name )
:>         String url = "jdbc:db2://"+server+":"+port+"/sample";
:>         String userid = getParameter("userid");
:>         String password = getParameter("password");
:>         // connect to database with userid and password
:>         con = DriverManager.getConnection(url, userid, password );
:>      } catch( Exception e ) {
:>         e.printStackTrace();
:>      }
:>   }
:>   public void paint(Graphics g) {
:>      try {
:>         // retrieve data from database
:>         g.drawString("First, let's retrieve some data from the
:>database...", 10, 10);
:>         Statement stmt = con.createStatement();
:>         ResultSet rs = stmt.executeQuery("SELECT * from employee");
:>         g.drawString("Received results:", 10, 25);
:>         // display the result set
:>         // rs.next() returns false when there are no more rows
:>         int y = 50;
:>         int i = 0;
:>         while (rs.next() && (i<2)) {
:>            i++;
:>            String a= rs.getString(1);
:>            String str = rs.getString(2);
:>            String oneLine = " empno= " + a + " firstname= " + str;
:>            g.drawString(oneLine, 20, y );
:>            y = y + 15;
:>         }
:>         stmt.close();
:>         // update the database
:>         g.drawString("Now, update the database...", 10, 100);
:>         stmt = con.createStatement();
:>         int rowsUpdated = stmt.executeUpdate("UPDATE employee set firstnme
:>= 'SHILI' where    empno = '000010'");
:>         // display the number of rows updated
:>         String msg = "Updated " + rowsUpdated;
:>         if (1 == rowsUpdated)
:>            msg = msg +" row.";
:>         else
:>            msg = msg +" rows.";
:>         y = y + 40;
:>         g.drawString(msg, 20, y);
:>         stmt.close();
:>      } catch( Exception e ) {
:>         e.printStackTrace();
:>      }
:>   }
:>This is the following error we recieved under internet explorer four (java
:>e]: cannot access "hal2"
:>   at com/ms/security/permissions/NetIOPermission.check
:>   at com/ms/security/PolicyEngine.deepCheck
:>   at com/ms/security/PolicyEngine.checkPermission
:>   at com/ms/security/StandardSecurityManager.chk
:>   at com/ms/security/StandardSecurityManager.chkex
:>   at com/ms/security/StandardSecurityManager.checkConnect
:>   at java/net/InetAddress.getAllByName0
:>   at java/net/InetAddress.getByName
:>   at java/net/Socket.<init>
:>   at COM/ibm/db2/jdbc/net/DB2Connection.create
:>   at COM/ibm/db2/jdbc/net/DB2Connection.<init>
:>   at COM/ibm/db2/jdbc/net/DB2Driver.connect
:>   at java/sql/DriverManager.getConnection
:>   at java/sql/DriverManager.getConnection
:>   at DB2Applt.init
:>   at com/ms/applet/AppletPanel.securedCall0
:>   at com/ms/applet/AppletPanel.securedCall
:>   at com/ms/applet/AppletPanel.processSentEvent
:>   at com/ms/applet/AppletPanel.processSentEvent
:>   at com/ms/applet/AppletPanel.run
:>   at java/lang/Thread.run
:>This is the error we got in Netscape 4.03:
:># Security Exception: Couldn't connect to 'hal2' with origin from ''.
:># Applet exception: class DB2Applt got a security violation:
:>security.Couldn't connect to 'hal2' with origin from ''.
:>netscape.security.AppletSecurityException: security.Couldn't connect to
:>'hal2' with origin from ''.
:>#  UniversalConnect privilege not enabled: Contacting and connecting with
:>other computers over a network
:>We adjusted WINDOWS NT  environmental settings (not autoexec.bat) and DB2
:>settings in the following manner:
:>IBM website suggested the following:
:>-  CLASSPATH includes "." and the file %DB2PATH%\java\db2java.zip
:>-  PATH includes the directory %DB2PATH%\bin
:>-  Ensure the LIB environment variable points to %DB2PATH\lib by using
:>   set LIB=%DB2PATH%\lib;%LIB%
:>-  Ensure that the DB2COMM environment variable is set at the server of a
:>remote    database
:>-  All DB2 environment variables can be defined in the user's environment
:>or set up as    registry variables.
:>-  DB2INSTANCE should only be defined at the user evironment level.  It is
:>not    required if you make use of    the DB2INSTDEF registry variable
:>which defines the    default instance name to use if DB2INSTANCE is not  
:>-  Ensure that the security service has started at the server for SERVER  
:>   authentication, and the client,       depending on the level of
:>authentication for    CLIENTauthentication.  To start the security service,
:>use the      
:>   NET START DB2NTSECSERVER command. WHAATTTT!!! and the list goes on  
:>for another 20 pages!!
:>What classpath, there is no classpath environmental setting in NT, and what
:>does the "." do.  %DB2PATH%, is that what we actually type in or do we type
:>in the path ex. c:\sqllib\etc....  These question may be stupid however we
:>are new to this.  We don't know were and how to apply half these settings
:>under DB2 or NTenvironment.  Hmm I wish they would give us some examples.
:>Someone helped us on some of our settings however we he still doesn't
:>understand some of provided material.
:>Several people told us to make sure that we run the applet off the server,
:>so we have made sure that both the applet and the database or located on
:>the server (HAL2 for us).
:>If it is possible, please give us step-by-step instructions on how to
:>install DB2, configuring DB2 and NT, and any other details required to have
:>a java applet access and update a DB2 database.
:>We are not sure if it is a problem with JAVA or JDBC or DB2, so if you have
:>any suggestions to resolving our problem, please get back to us as soon as
:>possible.  It is a matter of life and death!!
:>Thank-you for all your time and effort in helping us, we truly appreciate
:>NXXUS Systems Design

First of all, make sure you load your HTML page and the
applet from a "Webserver". For this, "Internet Information Server" (which
ships with Windows-NT but must be separately installed) will do just fine.
Once your webserver
is configured, put your Applet and HTML in a subdirectory
of the webservers document directory.

Then, before you launch your browser, make sure to run
"db2jstrt" with a unique portnumber, the same that you have
configured in your HTML page.

And last but not least make sure you load your Applet from
the server and not directly from the local harddisk. For this
your URL must start with
and never with "file:///c|...." etc.

If you want to set your local classpath for all applications and
permanently, login as Administrator to your Workstation and
go to the "System Settings", double click the "System" icon
and then click the "Environment" tab. here you can set your
Classpath, your Path and other settings you require.

Phone: +49 211 6914777  Mobile Phone: +49 172 2117822    Fax: +49 211 6914778
Email: gar...@ibm.net   CompuServe: 100023,3324          PGP Key on Request


Urgent! DB2 jdbc connection error

Post by David Harcomb » Wed, 11 Nov 1998 04:00:00

In addition to DB2Jstrt <port>, I seem to recall that the DB2 Security Server
service in NT needs to be started to allow Java applet access....

However, I've not had any problems like this for a while, so my recollection may
be faulty (we're using servlets and WebSphere Aplication Server).

David Harcombe
Gramercy Software Limited


1. Urgent: JDBC connect to DB2, SQL Exception : code page conversion error

I have installed a DB2 Workgroup edition server 7.1 in one machine
Windows 2000 Server and developing a java program running on a Windows
NT 4.0
machine with DB2 7.1 client installed.

The codepage for the server is set to 950 (traditional chinese big5).
And to avoid code page conversion, in the client, I use db2set to set
db2codepage to 950 also. And I found no problem for db connection
through db2 commandline (db2cmd).

However, when I use JDBC to connect (use native driver : COM.ibm.db2.j
dbc.app.DB2Driver), I get a SQL exception when using the DriverManager
java.sql.SQLException: Code page conversion tables do not exist
        at COM.ibm.db2.jdbc.app.DB2Connection.SQLConnect(Native Method)
        at COM.ibm.db2.jdbc.app.DB2Connection.connect(DB2Connection.java,
        at COM.ibm.db2.jdbc.app.DB2Connection.<init>(DB2Connection.java:321)
        at COM.ibm.db2.jdbc.app.DB2Driver.connect(DB2Driver.java:337)
        at java.sql.DriverManager.getConnection(DriverManager.java:457)
        at java.sql.DriverManager.getConnection(DriverManager.java:137)
        at testDB.main(testDB.java:13)
Exception in thread "main"

It seems that the db2 jdbc driver does not read the db2set environment

I am sure the necessary classpath is set (like db2java.zip and
runtime.zip are

How can I let DB2 know the client is also with codepage = 950 through
JDBC (since I don't want code page conversion. )



2. Q: use invalid_number to check alpha charater in varchar field ?

3. Urgent: DB2 code page conversion error through JDBC connect

4. Field/file names as variables

5. JDBC/DB2 Connection Error

6. SQL*Net,SQL*Link,PDox45W- HELP!

7. jdbc connection error with DB2 8.1 64-bit client

8. calling crystal report through sp

9. Differences between COM.ibm.db2.jdbc.app.DB2Driver and COM.ibm.db2.jdbc.net.DB2Driver

10. jdbc --->db2 (urgent!!!)

11. JDBC Error: CLI0647E Error allocating DB2 environmenment handle

12. Error accessing a JDBC Connection Object over a RMI Connection

13. Problem with the JDBC connection - URGENT