Professional Documents
Culture Documents
java
package labtest;
import java.awt.*;
import java.sql.*;
import java.awt .event.*;
import javax.swing.*;
un=new JTextField(10);
pw=new JPasswordField(10);
b1=new JButton("Login");
b1.addActionListener(this);
f1.add(a);f1.add(un);
f1.add(b);f1.add(pw);f1.add(b1);
f1.setLayout(new FlowLayout());
f1.setSize(200,400);
f1.setVisible(true);
}
void login()
{
try
{
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/hu","roo
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery("select * from tryu where username='"+un.ge
int c=0;
while(rst.next())
{
ysql://localhost/hu","root","");
ysql://localhost/hu","root","");
}
catch(Exception e2)
{
JOptionPane.showMessageDialog(null, e2);
}
}
void register()
{
try
{
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/hu","root
Statement stmt=con.createStatement();
int r=stmt.executeUpdate("insert into rtyu values('"+un.getText()+"','"+pw.
stmt.close();
con.close();
if(r>0)
{
JOptionPane.showMessageDialog(null, "REGISTER SUCESSFULLY");
}
else
{
JOptionPane.showMessageDialog(null, "REGISTRATION FAILD");
}
}
catch(Exception e2)
{
JOptionPane.showMessageDialog(null, e2);
}
}
sql://localhost/hu","root","");
'"+un.getText()+"','"+pw.getText()+"')");
SUCESSFULLY");
login();