> Hi,
>         I want to run an applet thro' HTML..using any Internet browsers.
I have written  Java application which runs on the command  prompt as
follows:
> java   FileName.Class

My program basically selects data from oracle database(Emp table) and
displays the Emp name(output) based on certain emp no.(input).
>
> I want to do the same from the HTML file.
> How can i achieve this? if possible then provide the code for the above.
>
   import java.io.*;
import java.util.*;
import java.sql.*;
class ex1{
     static int emp_no;
        static String enam;
  public void get(){
     try{

     DataInputStream  d = new DataInputStream(System.in);
     System.out.println(" Enter the Employee no.");
        String e_no = d.readLine();
        emp_no = Integer.parseInt(e_no);

     }    catch
     (Exception e){System.out.println("error :" +e);
        System.exit(1);
        }}


  public static void main(String arg[])
  throws Exception
  {
  ex1 ob = new ex1();
  ob.get();

    try{

        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        String dbUrl = "jdbc:odbc:dsn";
        Connection connl =
DriverManager.getConnection(dbUrl,"scott","tiger");
        Statement stmtl = connl.createStatement();
        ResultSet rs = stmtl.executeQuery("Select * from emp where empno='"
+emp_no+"'");
           int emp=0;

        while(rs.next() ){
                 emp = rs.getInt("empno");
             System.out.print(emp + "    ");
          //   System.out.println(rs.getString("ename"));}
             enam = rs.getString("ename");
            System.out.println(enam);
            }

       if(emp_no==emp){
        System.out.println("Empno : " + emp_no);
        System.out.println("Employee Name : " + enam);
        System.in.read();
        System.exit(1);
        }
       else {
       System.out.print("Invalid Empno");}
     }
     catch(Exception e) {
       e.getMessage();
     }
  //   stmtl.close();
 //    connl.close();
   }
 }


> Please Help.
> Regards,
> Devendra

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to