Advertisement
Guest User

Untitled

a guest
May 30th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. public String soMui(String tenBenh) {
  2. //        String ketQua = "";
  3. //        try {
  4. //            Class.forName("com.mysql.jdbc.Driver").newInstance();
  5. //            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/baitap?"
  6. //                    + "user=root&password=123456");
  7. //
  8. //            String sql = "select MaBenh from benh where TenBenh = '" + tenBenh + "'";
  9. //            PreparedStatement ps = conn.prepareStatement(sql);
  10. //
  11. //            ResultSet rs = ps.executeQuery();
  12. //            String MaBenh = "";
  13. //            while (rs.next()) {
  14. //                MaBenh = rs.getString("MaBenh");
  15. //            }
  16. //            
  17. //            if (!"".equals(MaBenh)) {
  18. //                sql = "select TenVacxin, SoMui from (vacxin, phongbenh) where vacxin.MaVacxin = phongbenh.MaVacxin and phongbenh.MaBenh = '" + MaBenh + "'";
  19. //                ps = conn.prepareStatement(sql);
  20. //                rs = ps.executeQuery();
  21. //
  22. //                while (rs.next()) {
  23. //                    ketQua += rs.getString("TenVacxin") + ": " + rs.getInt("SoMui") +"\n";
  24. //                }
  25. //            } else {
  26. //                ketQua = "Khong tim thay";
  27. //            }
  28. //
  29. //        } catch (ClassNotFoundException ex) {
  30. //            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
  31. //        } catch (SQLException ex) {
  32. //            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
  33. //        } catch (InstantiationException ex) {
  34. //            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
  35. //        } catch (IllegalAccessException ex) {
  36. //            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
  37. //        }
  38. //        return ketQua;
  39. //    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement