Hi.. to all...
in the following program i hav retrived data from the database and stored in the string s2,s3... now i hav display the following string in the textfields... i dont know how.. to do this... plz help me.........
Regards
pradeep
in the following program i hav retrived data from the database and stored in the string s2,s3... now i hav display the following string in the textfields... i dont know how.. to do this... plz help me.........
Regards
pradeep
Code:
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import sun.jdbc.odbc.*;
import java.io.*;
public class Viewcd extends Frame implements ActionListener
{
TextField ccod,cname,add,phno,conp,email,fax;
Label l1,l2,l3,l4,l5,l6,l7;
Button view,back;
String s1,s2,s3,s4,s5,s6,s7 ;
Connection con;
ResultSet rs;
Statement stmt;
public Viewcd()
{
super("VIEW ");
setSize(600,700);
setLayout(null);
setBackground(new java.awt.Color(245, 117, 105));
l1=new Label("ENTER THE CUSTOMERID");
l2=new Label("CompanyName");
l3=new Label("Address");
l4=new Label("PhoneNumber");
l5=new Label("Contact person");
l6=new Label("EmailAddress");
l7=new Label("FaxNumber");
l1.setBounds(20,60,170,70);
l2.setBounds(20,160,100,70);
l3.setBounds(20,220,100,70);
l4.setBounds(20,280,100,70);
l5.setBounds(20,340,100,70);
l6.setBounds(20,400,100,70);
l7.setBounds(20,460,100,70);
ccod=new TextField();
cname=new TextField();
add=new TextField();
phno=new TextField();
conp=new TextField();
email=new TextField();
fax=new TextField();
ccod.setBounds(220,80,120,30);
cname.setBounds(200,180,150,40);
add.setBounds(200,240,150,40);
phno.setBounds(200,300,150,40);
conp.setBounds(200,360,150,40);
email.setBounds(200,420,150,40);
fax.setBounds(200,480,150,40);
view= new Button("VIEW");
back= new Button("BACK");
view.setBounds(350,80,100,40);
back.setBounds(460,80,100,40);
view.addActionListener(this);
back.addActionListener(this);
add(l1);
add(ccod);
add(l2);
add(cname);
add(l3);
add(add);
add(l4);
add(phno);
add(l5);
add(conp);
add(l6);
add(email);
add(l7);
add(fax);
add(view);
add(back);
setVisible(true);
addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent w) {System.exit(0);}});
}
public void actionPerformed(ActionEvent ae)
{
int flag=0;
if(ae.getSource()==view)
{
s1=ccod.getText();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:prism");
stmt=con.createStatement();
rs=stmt.executeQuery("select * from Customerdetails");
while(rs.next())
{
if(rs.getString("CustomerID").equals(s1))
{
s1=(rs.getString(1));
s2=(rs.getString(2));
s3=(rs.getString(3));
s4=(rs.getString(4));
s5=(rs.getString(5));
s6=(rs.getString(6));
s7=(rs.getString(7));
}
}
}
catch(ClassNotFoundException e)
{
System.out.println(e);
}
catch(SQLException e)
{
System.out.println(e);
}
}
if(ae.getSource()==back)
{
this.hide();
Customerdetails cd = new Customerdetails();
}
}
public static void main(String args[])
{
Viewcd vd=new Viewcd();
}
}
Comment