Guest User

Untitled

a guest
Jul 31st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. SQL - how to return multiple rows with one SQL query?
  2. GLOBALSETTINGS
  3. ---------------------------------
  4. SessionTTL VARCHAR2(40 BYTE)
  5. MAXACTIVEUSERS NUMBER
  6. ACTIVEUSERS VARCHAR2(20 BYTE)
  7.  
  8. public String CheckUserDB(String userToCheck) throws SQLException {
  9. String storedPassword = null;
  10. String SQL_Statement = null;
  11.  
  12. if (ds == null) throw new SQLException();
  13. Connection conn = ds.getConnection();
  14. if (conn == null) throw new SQLException();
  15.  
  16. try {
  17. conn.setAutoCommit(false);
  18. boolean committed = false;
  19. try {
  20. SQL_Statement = "SELECT Passwd from USERS WHERE Username = ?";
  21.  
  22. PreparedStatement passwordQuery = conn.prepareStatement(SQL_Statement);
  23. passwordQuery.setString(1, userToCheck);
  24.  
  25. ResultSet result = passwordQuery.executeQuery();
  26.  
  27. if(result.next()){
  28. storedPassword = result.getString("Passwd");
  29. }
  30.  
  31. conn.commit();
  32. committed = true;
  33. } finally {
  34. if (!committed) conn.rollback();
  35. }
  36. }
  37. finally {
  38. conn.close();
  39.  
  40. }
  41.  
  42. return storedPassword;
  43. }
  44.  
  45. SELECT SessionTTL, MAXACTIVEUSERS, ACTIVEUSERS FROM GLOBALSETTINGS WHERE (condition)...
  46.  
  47. SELECT * FROM GLOBALSETTINGS WHERE (condition)...
  48.  
  49. string SqlAll = @"SELECT Database.SessionTTL, Database.MAXACTIVEUSERS, Database.ACTIVEUSERS FROM Database";
Add Comment
Please, Sign In to add comment