Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> applet only diaplay single row using oracle jdbc

applet only diaplay single row using oracle jdbc

From: <tedchyn_at_yahoo.com>
Date: Thu, 01 Apr 1999 03:32:45 GMT
Message-ID: <7dupct$5g8$1@nnrp1.dejanews.com>


Sir, when executing following code using netscape

     using "select * from emp" only a single row appers on the screen.
     question why following code did not work ? or it worked and not appear
     on the browser screen.
     please respond to tedchyn_at_yahoo.com
--------------------------------------------------------
     int i = 1;
					while (rset.next()){
						while (i<9){
					OutputInfo.appendText(rset.getString
      (i++) + "   ");

--------------------------------------------------------------
public class Project extends Applet {
          protected TextField InputField = null;
		  protected TextArea OutputInfo = null;
		  protected Button Query = null;
		  protected Button Clear = null;
		  protected Button Close = null;
		  protected String AnyQuery = "";

		  //JDBC Stuff
	static final String driver_class = "oracle.jdbc.driver.OracleDriver";

	static final String connect_string =
"jdbc:oracle:thin:scott/tiger_at_ABCD:1521:orcl";
		  Connection conn;

		  public void init() {
              initGUI();
			  reset();

          }

		  private void initGUI() {
			  setLayout(new BorderLayout());

			  InputField  = new TextField(300);
			  InputField.setEditable(true);

			  Panel grid = new Panel();
			  grid.setLayout(new GridLayout(1,3));
			  Query = new Button("Query");
			  Clear = new Button("Clear");
			  Close = new Button("Close");
			  OutputInfo = new TextArea();
			  OutputInfo.setEditable(false);


			  grid.add(Query);
			  grid.add(Clear);
			  grid.add(Close);
			  add ("North",InputField);
			  add("Center",OutputInfo);
			  add("South",grid);



			  show();


}
private void reset() { } /* private void destroy () {
}
*/ public boolean handleEvent(Event event) { switch (event.id) { case Event.ACTION_EVENT: if (event.target == Query) { try { AnyQuery = InputField.getText(); OutputInfo.setText(""); //see if we need to open a JDBC connection if (conn == null){ OutputInfo.appendText("Loading JDBC driver" + driver_class + "\n"); Class.forName (driver_class); //Connect to database OutputInfo.appendText ("Connecting....." + "\n"); conn = DriverManager.getConnection (connect_string); OutputInfo.appendText ("Connected\n"); } Statement stmt = conn.createStatement (); //Execute Query OutputInfo.setText("Executing Query " + AnyQuery + "\n"); ResultSet rset = stmt.executeQuery(AnyQuery); //dump the result int i = 1; while (rset.next()){ while (i<9){ OutputInfo.appendText(rset.getString (i++) + " "); } OutputInfo.appendText("\n"); } OutputInfo.appendText("Done\n"); } catch (Exception e) { OutputInfo.appendText (e.getMessage () + "\n"); } }else if (event.target == Clear){ OutputInfo.setText(""); InputField.setText(""); }else if (event.target == Close){ //destroy(); } break; default: return false; } return false;

    }

}

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed Mar 31 1999 - 21:32:45 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US