-
Notifications
You must be signed in to change notification settings - Fork 0
/
SupplierList.java
83 lines (70 loc) · 2.19 KB
/
SupplierList.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.table.DefaultTableModel;
import java.sql.*;
import java.sql.ResultSet;
public class SupplierList extends JFrame
{
JFrame jf=new JFrame();
JLabel ln;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
DefaultTableModel model = new DefaultTableModel();
JTable tabGrid = new JTable(model);
JScrollPane scrlPane = new JScrollPane(tabGrid);
public SupplierList()
{
jf.setLayout(null);
ln = new JLabel("List Of Supplier Details");
ln.setFont(new Font("Times New Roman",Font.BOLD,25));
ln.setForeground(Color.blue);
ln.setBounds(300,30,350,25);
jf.add(ln);
scrlPane.setBounds(0,80,900,600);
jf.add(scrlPane);
tabGrid.setFont(new Font ("Times New Roman",0,15));
model.addColumn("S_ID");
model.addColumn("S_NAME");
model.addColumn("S_Address");
model.addColumn("S_PhNo");
model.addColumn("S_EmailId");
int r = 0;
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/medical_store","root","");
System.out.println("Connected to database.");
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery("select * from supplier");
while(rs.next())
{
model.insertRow(r++,new Object[]{rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5)});
}
con.close();
}
catch(SQLException se)
{
System.out.println(se);
JOptionPane.showMessageDialog(null,"SQL Error:"+se);
}
catch(Exception e)
{
System.out.println(e);
JOptionPane.showMessageDialog(null,"Error:"+e);
}
jf.setTitle("Supplier List");
jf.setSize(900,700);
jf.setLocation(20,20);
jf.setResizable(false);
jf.getContentPane().setBackground(Color.cyan);
jf.setVisible(true);
}
public static void main(String args[])
{
new SupplierList();
}
}