× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: SQLException 9999:9999 getConnection - stack trace & complete program
  • From: "Steve Swett" <swett@xxxxxxxxxxxxxx>
  • Date: Fri, 9 Mar 2001 07:51:13 -0500

This short java application uses Toolbox for Java to use JDBC and SQL to
read in a result set and then load the first result set record into a
combobox.  Very easy -- just to test AS/400 db connectivity.  Surprisingly,
it won't work.  Here's the stack trace and complete source code.  Any ideas?

I'm using: OS/400 V4R4, the jt400.zip file that comes with Client Access
V4R4M0 service level SF60796, and JBuilder4 IDE.  I'm using the JRE that is
supplied with JBuilder4 (from the c:\jbuilder4\jdk1.3\bin folder).


Steve's note: * SQL Exception occurred error is 9999:9999 string is
java.sql.SQLException: 9999:9999 *
java.sql.SQLException: 9999:9999
 at com.ibm.as400.access.JDError.throwSQLException(JDError.java:324)
 at
com.ibm.as400.access.AS400JDBCConnection.open(AS400JDBCConnection.java:1070)
 at
com.ibm.as400.access.AS400JDBCConnection.<init>(AS400JDBCConnection.java:244
)
 at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:221)
 at java.sql.DriverManager.getConnection(DriverManager.java:517)
 at java.sql.DriverManager.getConnection(DriverManager.java:177)
 at
test400db.test400dbFrame.jButton1_actionPerformed(test400dbFrame.java:58)
 at test400db.test400dbFrame$1.actionPerformed(test400dbFrame.java:30)
 at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
 at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButto
n.java:1504)
 at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:3
78)
 at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
 at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener
.java:216)
 at java.awt.Component.processMouseEvent(Component.java:3717)
 at java.awt.Component.processEvent(Component.java:3546)
 at java.awt.Container.processEvent(Container.java:1164)
 at java.awt.Component.dispatchEventImpl(Component.java:2595)
 at java.awt.Container.dispatchEventImpl(Container.java:1213)
 at java.awt.Component.dispatchEvent(Component.java:2499)
 at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
 at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
 at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
 at java.awt.Container.dispatchEventImpl(Container.java:1200)
 at java.awt.Window.dispatchEventImpl(Window.java:912)
 at java.awt.Component.dispatchEvent(Component.java:2499)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
 at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)


package test400db;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import com.ibm.as400.access.*;

public class test400dbFrame extends JFrame {
  JPanel contentPane;
  JButton jButton1 = new JButton();
  JComboBox jComboBox1 = new JComboBox();

  /**Construct the frame*/
  public test400dbFrame() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  /**Component initialization*/
  private void jbInit() throws Exception  {
    jButton1.setText("Connect & Load");
    jButton1.setBounds(new Rectangle(13, 17, 162, 36));
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });

//setIconImage(Toolkit.getDefaultToolkit().createImage(test400dbFrame.class.
getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(null);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Test of AS/400 Database Connections");
    jComboBox1.setBounds(new Rectangle(12, 72, 164, 38));
    contentPane.add(jButton1, null);
    contentPane.add(jComboBox1, null);
  }
  /**Overridden so we can exit when window is closed*/
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }

  void jButton1_actionPerformed(ActionEvent e) {

  try {

  // Register AS/400 JDBC Driver:
  DriverManager.registerDriver (new AS400JDBCDriver ());

  // Connect to AS/400:
  Connection c = DriverManager.getConnection(
    "jdbc:as400://myas400;naming=sql;errors=full",
    "myuser",
    "mypwd");

  // Run a query to load a result set:

     // First create an SQL statement:
     Statement s = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                     ResultSet.CONCUR_READ_ONLY);

     // Then execute a statement:
     ResultSet rs = s.executeQuery (
       "SELECT STDNAM FROM BCSSTUDENT.PAOSSTU WHERE STDCLS = '11' ORDER BY
STDNAM");

    // Then loop through ResultSet records to load combo box:
    // For now, just load first student so we don't have to wait.
    rs.first();
    jComboBox1.addItem(rs.getString("STDNAM"));

    // Close the statement and disconnect:
    s.close();
    c.close();

  }   // try

  catch (SQLException sqle) {
    System.out.println("Steve's note: * SQL Exception occurred" +
      " error is " + sqle.getMessage() + " string is " +
      sqle.toString() + " * "  );

    sqle.printStackTrace();

  }   // catch

  }
}

+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.