From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078715811455.tru64-unix-managers.marc@archive.invalid> From: jackb () pgw ! picker ! com Date: Thu, 02 Jul 1998 11:37:02 +0000 To: tru64-unix-managers Subject: SUMMARY: Having Java Difficulties ... X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078715811455 I managed to get the jdbc-thin sample applet working shortly after posting the message. I made the following two changes to the java source //output.setText (null); output.setText (""); // Class.forName (driver_class); Class t = Class.forName (driver_class); Write Once Run Anywhere??? ########################################################### Original Post Follows: To: alpha-osf-managers@ornl.gov Subject: Having Java Difficulties ... 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@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: JDBC applet

JDBC applet

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

The source code for the applet is in JdbcApplet.java. Please check carefully the driver class name and the connect string in the code.

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.

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