Guest User

Untitled

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