import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
class custdetfrm extends JFrame
{
Connection con=null;
Integer i=0,j;
public custdetfrm(String s)
{
super(s);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e)
{
System.out.println("ads");
}
try
{
con=DriverManager.getConnection("jdbc:odbc:cst1");
}
catch(SQLException se)
{
System.out.println(se);
}
System.out.println("connection successful......");
Container c=getContentPane();
try
{
String dat[][]=new String[4][4];
String col[]={
"cust_id","cust_name","cust_bill","cust_city"
};
String selectqr = "select * from cust_det";
System.out.println(selectqr);
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery(selectqr);
i=0;
while(rset.next())
{
for(j=1;j<=4;j++)
{
dat[i][j-1]=rset.getString(j);
}
i++;
}
JTable t=new JTable(dat,col);
c.add(t);
stmt.close();
}
catch(SQLException se)
{
System.out.println(se);
}
}
}
class custpg
{
public static void main(String[] s)
{
custdetfrm f= new custdetfrm("customer detail page");
f.setSize(400,400);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
No comments:
Post a Comment