Having Java Difficulties ...

From: <jackb_at_pgw.picker.com>
Date: Wed, 01 Jul 1998 08:35:55 -0400

I must be missing something!

I have downloaded the jdbcthin.tar file for Unix, from Oracles Web Page
(http://www.oracle.com/nca/java_nca/jdbc/v7/html/download.html). This
tar file contains the classes111.zip (jdbc thin driver) file and some
samples. The JdbcApplet.java and JdbcApplet.htm in the directory
samples/thin reside in the htdocs directory on my Alpha 3700 running
DU 4.0D and JDK 1.1.6. This jdbc-thin test applet works fine when it
is accessed via a browser from a Win-95 system, but not from a browser
or even the appletviewer on the Alpha console.

>From the Win-95 machine, the applet is executed. When I press the
"Hello JDBC" button I get connected to the Oracle database and
get the results I expect.

>From the Alpha Console (Netscape Communicator 4.05 Browser or Appletviewer),
the applet is executed. When I press the "Hello JDBC" button I get the word
"null". No errors are generated in the Java Console Window.

I get the same results using JDK 1.1.4, 1.1.5, and 1.1.6
I have checked all available documentation and have found no resolution.
Can someone please clue me in?

Thank you,

Jack Burton

################################################################################
########
The Java Source file (JdbcApplet.java) follows:

/*
 * This sample applet just selects 'Hello World' and the date from the database
 */

// Import the JDBC classes
import java.sql.*;

// Import the java classes used in applets
import java.awt.*;
import java.io.*;
import java.util.*;

public class JdbcApplet extends java.applet.Applet
{
  // The driver to load
  static final String driver_class = "oracle.jdbc.driver.OracleDriver";

  // The connect string
  static final String connect_string =
                  "jdbc:oracle:thin:mylogin/mypass_at_pgw6:1521:repair";

  // The query we will execute
  static final String query = "select 'Hello JDBC: ' || sysdate from dual";

  // The button to push for executing the query
  Button execute_button;

  // The place where to dump the query result
  TextArea output;

  // The connection to the database
  Connection conn;

  // Create the User Interface
  public void init ()
  {
    this.setLayout (new BorderLayout ());
    Panel p = new Panel ();
    p.setLayout (new FlowLayout (FlowLayout.LEFT));
    execute_button = new Button ("Hello JDBC");
    p.add (execute_button);
    this.add ("North", p);
    output = new TextArea (10, 60);
    this.add ("Center", output);
  }

  // Do the work
  public boolean action (Event ev, Object arg)
  {
    if (ev.target == execute_button)
    {
      try
      {
        // Clear the output area
        output.setText (null);

        // See if we need to open the connection to the database
        if (conn == null)
        {
          // Load the JDBC driver
          output.appendText ("Loading JDBC driver " + driver_class + "\n");
          Class.forName (driver_class);

          // Connect to the databse
          output.appendText ("Connecting to " + connect_string + "\n");
          conn = DriverManager.getConnection (connect_string);
          output.appendText ("Connected\n");
        }

        // Create a statement
        Statement stmt = conn.createStatement ();

        // Execute the query
        output.appendText ("Executing query " + query + "\n");
        ResultSet rset = stmt.executeQuery (query);

        // Dump the result
        while (rset.next ())
          output.appendText (rset.getString (1) + "\n");

        // We're done
        output.appendText ("done.\n");
      }
      catch (Exception e)
      {
        // Oops
        output.appendText (e.getMessage () + "\n");
      }
      return true;
    }
    else
      return false;
  }
}

#############################################################################
The Html file (JdbcApplet.htm) follows:

<html>
<head>
<title>JDBC applet</title>
</head>
<body>

<h1>JDBC applet</h1>

This page contains an example of an applet that uses the Thin JDBC
driver to connect to Oracle.<p>

The source code for the applet is in <a
href="JdbcApplet.java">JdbcApplet.java</a>. Please check carefully
the driver class name and the connect string in the code.<p>

The Applet tag in this file contains a CODEBASE entry that must be set
to point to a directory containing the Java classes from the Thin JDBC
distribution *and* the compiled JdbcApplet.class.<p>

As distributed it will *not* work because the classes111.zip are not
in this directory.<p>

<hr>
<applet codebase="." archive="classes111.zip"
code="JdbcApplet" width=500 height=200>
</applet>
<hr>
Received on Wed Jul 01 1998 - 14:35:05 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:38 NZDT