-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentId.java
More file actions
92 lines (81 loc) · 2.09 KB
/
StudentId.java
File metadata and controls
92 lines (81 loc) · 2.09 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
package View;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import form.MyConnection;
public class StudentId
{
JTable table;
JScrollPane jsp;
JDialog dialog;
String []columns;
String data[][];
int cnt,c,r;
String er;
public StudentId(String er)
{
this.er=er;
String s = "select * from stacademicdetail where Er_No=?";
Connection con = MyConnection.connect1();
try
{
PreparedStatement ps = con.prepareStatement(s);
ps.setString(1, er);
ResultSet rs = ps.executeQuery();
rs.last();
cnt=rs.getRow();
rs.beforeFirst();
columns = new String[]{"Er_No","Name","Branch","Mobile","Email"};
data = new String[cnt][5];
while(rs.next())
{
data[r][c]=String.valueOf(rs.getInt("Er_No"));
++c;
data[r][c]=rs.getString("Name");
++c;
data[r][c]=rs.getString("Branch");
++c;
data[r][c]=rs.getString("Mobile");
++c;
data[r][c]=rs.getString("Email");
c=0;
++r;
}
table=new JTable(data,columns);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
jsp= new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
dialog = new JDialog();
dialog.setModal(true);
dialog.setTitle("Tabular Display");
dialog.setLayout(null);
dialog.setSize(500,400);
JButton back = new JButton("back");
back.setBounds(10, 5, 80, 30);
jsp.setBounds(10, 50, 300, 200);
back.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
dialog.add(back);
dialog.add(jsp);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}
catch(SQLException se)
{
se.printStackTrace();
}
}
public static void main(String[] args)
{
}
}