Reputation: 17
I want to open agent form after clicking on the button login, which I can't understand.
I have a table named agent having attributes User_Name, Password, First_Name and Last_Name.
I take input from user in User_Name and Password for login. After matching the values, it must move to next form of agent and display information.
If it becomes true than proceed to agent information.
private void jButton1_LogInActionPerformed(java.awt.event.ActionEvent evt) {
Connection con = MyConnection.getConnection();
PreparedStatement ps;
try {
ps=con.prepareStatement("Select * from agent WHERE User_Name = ? AND Password = ?");
ps.setString(1, jTextField1_UserName.getText());
ps.setString(2, String.valueOf(jPasswordField1.getPassword()));
ResultSet rs = ps.executeQuery();
String Name = jTextField1_UserName.getText();
if(rs.next())
{
String First_Name = rs.getString("First_Name");
if(Name.equals(First_Name))
{
Agent_Info ag_info = new Agent_Info();
ag_info.setVisible(true);
ag_info.pack();
ag_info.setLocationRelativeTo(null);
this.dispose();
//System.out.println("Yes");
}
}
} catch (SQLException ex) {
Logger.getLogger(LoginForm.class.getName()).log(Level.SEVERE, null, ex);
}
What can I do for completion of this task?
Upvotes: 0
Views: 134