-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_b1.java
More file actions
169 lines (112 loc) · 3.68 KB
/
admin_b1.java
File metadata and controls
169 lines (112 loc) · 3.68 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Date;
import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class admin_b1 extends JFrame
implements ActionListener
{
JTextField tf1;
JButton b1,b2,b3;
JLabel l1,l2;
JScrollPane pane;
JTextArea area;
public void admin_b1_UI()
{
super.setBounds(100, 50, 1000, 600);
super.setTitle("ALL USER INFO");
super.setResizable(false);
b1 = new JButton("ALL USERS");
b1.setBounds(50, 80, 250, 40);
super.add(b1);
b1.setBackground(Color.green);
b1.setForeground(Color.black);
b1.addActionListener(this);
b2 = new JButton("CRIETRIA");
b2.setBounds(50, 150, 250, 40);
super.add(b2);
b2.setBackground(Color.green);
b2.setForeground(Color.black);
b2.addActionListener(this);
b3 = new JButton("MODIFY DETAILS");
b3.setBounds(50, 220, 250, 40);
super.add(b3);
b3.setBackground(Color.green);
b3.setForeground(Color.black);
b3.addActionListener(this);
area = new JTextArea();
pane = new JScrollPane(area);
pane.setBounds(350, 50, 500, 500);
super.add(pane);
area.setEditable(false);
// 3rd last
super.setLayout(null);
// 2nd last
super.setVisible(true);
//last st
super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
try {
//step 1 loading driver file
Class.forName("com.mysql.jdbc.Driver");
//step 2 get connection
Connection co= DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/bankdb","root","root");
//step 3 get statement
Statement st1=co.createStatement();
//Statement st2=co.createStatement();
if(ae.getSource()==b1)
{
ResultSet rs1 = st1.executeQuery("select * from userinfo");
String name = null ;String mobile = null ;String email = null;String address = null;
while(rs1.next())
{
name = rs1.getString("NAME");
mobile = rs1.getString("MOBILE");
email = rs1.getString("email");
address = rs1.getString("address");
//System.out.printf("%-15s %-15s %-15s %-15s %n",name,email,mobile,address);
// String showA = (name+" "+email+" "+mobile+" "+address);
//JOptionPane.showMessageDialog(this, name);
//area.setText(showA);
area.setText(name+email+mobile+address);
}
//step 5 closing
co.close();
}}catch(Exception ex)
{
ex.printStackTrace();
}
System.out.println("******************************************************************************");
String a = "NAME";String b="EMAIL";String c="MOBILE";String d="ADDRESS";
System.out.printf("%-15s %-15s %-15s %-15s %n",a,b,c,d);
System.out.println("----- ------- ---------- ---------");
}
public static void main(String[] args)
{
admin_b1 runx = new admin_b1();
runx.admin_b1_UI();
}
}