hacker_yusu

Untitled

Nov 14th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. try{
  2.                 Class.forName("com.mysql.jdbc.Driver");
  3.                 con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bank","root","fatalcoder524");
  4.                 PreparedStatement stmt=con.prepareStatement("select * from accounts where "+searchstr+"=?");
  5.                 stmt.setString(1, jTextField1.getText());
  6.                 ResultSet rs = stmt.executeQuery();
  7.                 if(rs.next())
  8.                 {
  9.                     JOptionPane.showMessageDialog(null, "Account or Customer ID found.", "Account Status", JOptionPane.INFORMATION_MESSAGE);
  10.                     con.close()
  11.                 }
  12.                 else
  13.                 {
  14.                     JOptionPane.showMessageDialog(null, "No Account or Customer ID found.", "Deposit Status", JOptionPane.ERROR_MESSAGE);
  15.                     con.close();
  16.                 }
  17.             }catch(Exception e)
  18.             {
  19.                 System.out.println(e);
  20.             }
Add Comment
Please, Sign In to add comment