Guest User

Untitled

a guest
Dec 3rd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public class UserDAO {
  2. //ログイン名 パスワード が一致する数を返す
  3. //@param roginName ログイン名
  4. //@param password パスワード
  5. //@return 結果を返す
  6. public int getCount(String loginName, String password) {
  7.  
  8. int cnt = 0;
  9.  
  10. try(
  11. Connection con =
  12. DriverManager.getConnection("jdbc:oracle:thin:@xx.xx.xx.xx:1521:xxxx", "xxx", "xxx");
  13. Statement stmt = con.createStatement();
  14. ResultSet rs = stmt.executeQuery(
  15. "select ID, 氏名, パスワード, ログイン名 from 異常系1_ユーザーマスタ order by ID asc");
  16. )
  17. {
  18. while(rs.next()) {
  19. if(rs.getString("ログイン名").equals(loginName) && rs.getString("パスワード").contentEquals(password)) {
  20. cnt++;
  21. }
  22. }
  23. }
  24. catch(SQLException ex) {
  25. cnt = 0;
  26. }
  27.  
  28. return cnt;
  29. }
Add Comment
Please, Sign In to add comment