-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiniStatement.java
More file actions
37 lines (31 loc) · 1.19 KB
/
Copy pathMiniStatement.java
File metadata and controls
37 lines (31 loc) · 1.19 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
import javax.swing.*;
import java.awt.*;
import java.sql.*;
public class MiniStatement extends JFrame {
MiniStatement(String cardNumber) {
setTitle("Mini Statement");
setLayout(new BorderLayout());
JTextArea area = new JTextArea();
area.setEditable(false);
area.setFont(new Font("Monospaced", Font.PLAIN, 14));
add(new JScrollPane(area), BorderLayout.CENTER);
try {
Conn conn = new Conn();
ResultSet rs = conn.s.executeQuery(
"SELECT * FROM bank WHERE card_number = '" + cardNumber + "' ORDER BY date DESC LIMIT 5");
area.append("Date\t\tType\tAmount\n");
area.append("----------------------------------------\n");
while (rs.next()) {
area.append(rs.getString("date") + "\t" + rs.getString("type") + "\t" + rs.getString("amount") + "\n");
}
} catch (Exception e) {
area.setText("Error loading transactions: " + e.getMessage());
}
setSize(500, 300);
setLocation(450, 250);
setVisible(true);
}
public static void main(String[] args) {
new MiniStatement("1234567890123456");
}
}