tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: jackb () pgw ! picker ! com
To: tru64-unix-managers
Subject: Having Java Difficulties ...
Date: Wed, 01 Jul 1998 12:35:55 +0000	[thread overview]
Message-ID: <96078715811417.tru64-unix-managers.marc@archive.invalid> (raw)

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@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>

                 reply	other threads:[~1998-07-01 12:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox