-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChangePassword.java
197 lines (178 loc) · 3.72 KB
/
ChangePassword.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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
class ChangePassword extends JPanel implements ActionListener
{ JLabel l1,l2,l3,l4;
JTextField tf1,tf2,tf3,tf4;
JPasswordField jpf1,jpf2,jpf3;
JButton b1,b2;
Connection con;
PreparedStatement pstmt;
ResultSet res;
public ChangePassword()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e)
{
System.out.println("yyyyyyy");
//e.printStackTrace();
}
try
{
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","lms","lms");
}
catch(SQLException s)
{
System.out.println("tttttttttt");
//s.printStackTrace();
}
setSize(600,600);
setLayout(new GridBagLayout());
l1=new JLabel("User ID:");
l2=new JLabel("Old Password:");
l3=new JLabel("New Password:");
l4=new JLabel("Confirm Password:");
tf1=new JTextField();
jpf1=new JPasswordField();
jpf2=new JPasswordField();
jpf3=new JPasswordField();
b1=new JButton("OK");
b1.addActionListener(this);
b2=new JButton("CANCEL");
b2.addActionListener(this);
GridBagConstraints gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=2;
gc.ipadx=0;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,0,0,130);
add(l1,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=3;
gc.ipadx=300;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,130,0,0);
add(tf1,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=4;
gc.ipadx=0;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,0,0,100);
add(l2,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=5;
gc.ipadx=300;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,130,0,0);
add(jpf1,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=6;
gc.ipadx=0;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,0,0,100);
add(l3,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=7;
gc.ipadx=300;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,130,0,0);
add(jpf2,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=8;
gc.ipadx=0;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,0,0,80);
add(l4,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=9;
gc.ipadx=300;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,130,0,0);
add(jpf3,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=10;
gc.ipadx=20;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,0,0,80);
add(b1,gc);
gc=new GridBagConstraints();
gc.gridx=2;
gc.gridy=10;
gc.ipadx=0;
gc.ipady=0;
gc.weightx=0.5;
gc.weighty=0.5;
gc.insets=new Insets(0,80,0,0);
add(b2,gc);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
try
{
String str1=tf1.getText();
char chr[]=jpf1.getPassword();
String str2=String.valueOf(chr);
char chr1[]=jpf2.getPassword();
String str3=String.valueOf(chr1);
String query1="select LOGIN_ID from Login";
pstmt=con.prepareStatement(query1);
res=pstmt.executeQuery();
while(res.next())
{
String strr1=res.getString("LOGIN_ID");
if(strr1.equalsIgnoreCase(str1))
{
String query2="update LOGIN SET PASSWORD=? where LOGIN_ID='admin'";
pstmt=con.prepareStatement(query2);
pstmt.setString(1,str3);
//pstmt.setString(2,str1);
int vb=pstmt.executeUpdate();
}
}
}
catch(SQLException pp)
{
System.out.println("mmmmm");
//pp.printStackTrace();
}
}
else if(ae.getSource()==b2)
{
}
else
{
}
}
}