0
import java.awt.*;
import java.applet.*;
import java.awt.Event;
import java.awt.event.ActionListener;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;




//private Connection connection=null;
//private Statement st=null;
//private ResultSet rs=null;

public class Example extends Applet implements ActionListener,Connection
{

public void init()
     {

Connection con=null;
Statement st=null;
ResultSet rs=null;

String qa="insert into demo1 values(' ',' ',' ',' ',' ')";

    
try       {
      
Class.forName("oracle.jdbc.driver.OracleDriver");//.newInstance();
      
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","hr","hr");
	
Statement st=con.createStatement();
 

ResultSet rs=st.executeQuery(qa);
 
   

setLayout(null);

Button okButton = new Button("Submit"); 

okButton.addActionListener(this);

TextField Employee_Name = new TextField("",30);

TextField Employee_Id= new TextField("",30);

TextField Department = new TextField("",30);

TextField Email_Id = new TextField("",30);

TextField salary = new TextField("",30);



Employee_Name.setBounds(300,50,150,25);

Employee_Id.setBounds(300,120,150,25);

Department.setBounds(300,190,150,25);

Email_Id.setBounds(300,260,150,25);

salary.setBounds(300,330,150,25);

okButton.setBounds(350,370,50,25); 


add(Employee_Name);

add(Employee_Id);

add(Department);

add(Email_Id);

add(Salary);

add(okButton);
}

catch (Exception connectException) 
{
      
   connectException.printStackTrace();
   
 }

catch (Exception e){

throw new Exception(e);

}

public void actionPerformed(Event evt)
                   {

if(evt.getSource()==okButton)
                       {

 while(rs.next())
{

String Employee_Name=rs.getString("Employee_Name");

int Employee_Id=rs.getInt("Employee_Id");

String Department=rs.getString("Department");

String Email_Id=rs.getString("Email_Id");

int Salary=rs.getInt("salary");

//repaint();

                         }
rs.close();


                  }


                 } 

con.commit();

st.close();

con.close();
 
           }
 
public void paint(Graphics g){

setBackground(Color.pink);

g.setColor(Color.black);

g.drawString("Employee Name",150,70);

g.drawString("Employee Id",150,140);

g.drawString("Department",150,210);

g.drawString("Email Id",150,280);

g.drawString("Salary",150,350);

	                             }


}

Please anyone debug this code attached corrected program to this mail id : <EMAIL SNIPPED>

Thanks

Edited by peter_budo: Do use code tags when posting code, do NOT post your email address

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by peter_budo
0

What are all the jar files can be added while creating the jdbc connection to run in command prompt

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.