Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String hospitalName = hospitalTF.getText();
- String userClass;
- Connection connection = null;
- Statement stmt = null;
- PreparedStatement pst = null;
- ResultSet rs = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- connection = DriverManager
- .getConnection("jdbc:mysql://localhost:3306/healthapp", "root", "");
- pst = connection.prepareStatement("select * from HOSPITAL where Username=? ");
- pst.setString(1, hospitalName);
- rs = pst.executeQuery();
- if (rs.next()) {
- userClass = rs.getString("Class");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- stmt.close();
- connection.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement