Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> APPLET - JDBC - Oracle question
Hello everyone,
I have problems connecting from an applet to an oracle database. I have detailed it below.
Any of you who have worked on the above can you please help. The actual code is below.
Thanks,
jude
import jdbc.sql.* ; import java.io.* ; import java.util.Date ; import java.applet.Applet ; import java.awt.* ;
// This says jdbc_Awt_applet class inherits from Applet object
public class java_2 extends Applet
{
//-------------------------------------------------------------
// CLASS ATTRIBUTES
//
// All are prefixed with "v_" to signify they are variables / objects
//-------------------------------------------------------------
TextArea v_text_area_output = new TextArea();// Place to display the output
Label v_status_bar = new Label(); Button v_button; // button to execute the query Connection conn; // connection to database
//-------------------------------------------------------------
// CLASS METHIDS
//-------------------------------------------------------------
//-------------------------------------------------------------
// Method-1 ( Constructor )
//-------------------------------------------------------------
public void init()
{
// create the user interface
setLayout(null);
v_button= new Button("Click me to get data");
v_text_area_output = new TextArea(10,10);
add("Center", v_text_area_output); add(v_button); v_button.reshape(15,9,100,26); v_text_area_output.reshape(125,10,200,50);
}
// end init
public boolean action(Event v_event, Object v_arg) {
if (v_event.target == v_button) { try { // clear the output area v_text_area_output.setText(null); // check if we need to open connection to db if ( conn == null ) { // Load JDBC driver v_text_area_output.appendText("Loading JDBC driver ..."); Class.forName("oracle.jdbc.driver.OracleDriver"); // Connect to db Connection conn = DriverManager.getConnection
v_text_area_output.appendText("Connected to machine ...");
}
// Create the statement
Statement stmt = conn.createStatement();
//Execute the query
ResultSet rset = stmt.executeQuery("Select PO_CTY_NM from CUSTOMER where rownum < 10");
// Display the output
while ( rset.next()) { v_text_area_output.appendText(rset.getString(1) + "\n"); showStatus("data " + rset.getString(1) ); } // end while } catch (Exception e ) // generic error handler { v_text_area_output.appendText(e.getMessage() + " ooops \n"); } return true; } else return false;
} // end class definition
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Apr 09 1999 - 09:06:04 CDT