Repository navigation
Expand file tree
/
Copy pathTopPerformerFrame.java
More file actions
98 lines (68 loc) · 2.21 KB
/
Copy pathTopPerformerFrame.java
File metadata and controls
98 lines (68 loc) · 2.21 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.ems.gui.employee;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.ems.db.DBConnection;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class DisplayEmployeeFrame extends JFrame {
public DisplayEmployeeFrame() {
setTitle("Display Employees");
setSize(900, 500);
setLocationRelativeTo(null);
setLayout(null);
setDefaultCloseOperation(
JFrame.DISPOSE_ON_CLOSE);
String columnNames[] = {
"ID",
"Name",
"Salary",
"Department",
"Designation",
"Email",
"Phone"
};
javax.swing.table.DefaultTableModel model =
new javax.swing.table.DefaultTableModel(
columnNames,
0
);
JTable table =
new JTable(model);
try {
Connection con =
DBConnection.getConnection();
String query =
"select * from employee";
PreparedStatement ps =
con.prepareStatement(query);
ResultSet rs =
ps.executeQuery();
while(rs.next()) {
Object row[] = {
rs.getInt("employee_id"),
rs.getString("name"),
rs.getDouble("salary"),
rs.getString("department"),
rs.getString("designation"),
rs.getString("email"),
rs.getString("phone_number")
};
model.addRow(row);
}
}
catch(Exception e) {
System.out.println(e);
}
JScrollPane scrollPane =
new JScrollPane(table);
scrollPane.setBounds(
20,
20,
840,
400);
add(scrollPane);
setVisible(true);
}
}