-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcode.txt
56 lines (51 loc) · 1.69 KB
/
code.txt
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
TO INSERT DETAILS INTO A TABLE:
String x1=jTextField1.getText();
String x2=jTextField2.getText();
try
{
Connection conn;
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","password");
String sql="insert into login values('"+x1+"','"+x2+"')";
Statement stm;
stm=conn.createStatement();
stm.executeUpdate(sql);
setVisible(false);
new Form1().setVisible(true);
}
catch( ClassNotFoundException | SQLException e)
{
}
TO CHECK USERNAME AND PASSWORD:
String x1=jTextField1.getText();
String x2=jTextField2.getText();
try
{
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
Connection conn;
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","password");
String s="select * from login where uname='"+x1+"' and pwd='"+x2+"';";
Statement stm=conn.createStatement();
rs=stm.executeQuery(s);
int count=0;
while(rs.next())
{
count++;
}
if(count==1)
{
System.out.println("password matched");
new Form3().setVisible(true);
}
else
{
System.out.println("wrong password");
}
}
catch(ClassNotFoundException e)
{
}
catch (SQLException ex) {
Logger.getLogger(Form1.class.getName()).log(Level.SEVERE, null, ex);
}