Advertisement
Guest User

Untitled

a guest
Mar 10th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. String hospitalName = hospitalTF.getText();
  2. String userClass;
  3.  
  4. Connection connection = null;
  5. Statement stmt = null;
  6. PreparedStatement pst = null;
  7. ResultSet rs = null;
  8.  
  9. try {
  10. Class.forName("com.mysql.jdbc.Driver");
  11. connection = DriverManager
  12. .getConnection("jdbc:mysql://localhost:3306/healthapp", "root", "");
  13.  
  14. pst = connection.prepareStatement("select * from HOSPITAL where Username=? ");
  15. pst.setString(1, hospitalName);
  16. rs = pst.executeQuery();
  17. if (rs.next()) {
  18. userClass = rs.getString("Class");
  19. }
  20. } catch (Exception e) {
  21. e.printStackTrace();
  22. } finally {
  23. try {
  24. stmt.close();
  25. connection.close();
  26. } catch (Exception e) {
  27. e.printStackTrace();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement