- Timestamp:
- 2013-09-06T11:17:55+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java
r28219 r28233 335 335 try 336 336 { 337 System.err.println("xx" + conn.isClosed()); 337 338 Statement state = conn.createStatement(); 338 339 ResultSet rs = state.executeQuery("SELECT * FROM " + DATA + " WHERE username='" + username + "' AND name='" + name + "'"); 339 340 conn.commit(); 340 state.close();341 341 if (rs.next()) 342 342 { … … 347 347 found = false; 348 348 } 349 state.close(); 349 350 } 350 351 catch (Exception ex) … … 354 355 { 355 356 printSQLError((SQLException) ex); 357 ex.printStackTrace(); 356 358 } 357 359 else … … 411 413 ResultSet rs = state.executeQuery("SELECT * FROM " + DATA + " WHERE username='" + username + "' AND name='" + name + "'"); 412 414 conn.commit(); 413 state.close();414 415 if (rs.next()) 415 416 { 416 417 return rs.getString("value"); 417 418 } 419 state.close(); 418 420 } 419 421 catch (Exception ex) … … 423 425 { 424 426 printSQLError((SQLException) ex); 427 ex.printStackTrace(); 425 428 } 426 429 else … … 607 610 // findUser(null) will return all users, which is why a UserQueryResult 608 611 // (a vector of UserTermInfo) is returned 609 public UserQueryResult findUser(String username) throws SQLException612 public UserQueryResult findUser(String username) 610 613 { 611 614 UserQueryResult userQueryResult = new UserQueryResult(); … … 625 628 ArrayList<HashMap<String, String>> users = new ArrayList<HashMap<String, String>>(); 626 629 627 Statement state = conn.createStatement();628 ResultSet rs = state.executeQuery(sql_find_user);629 conn.commit();630 while (rs.next())631 {632 HashMap<String, String> user = new HashMap<String, String>();633 user.put("username", rs.getString("username"));634 user.put("password", rs.getString("password"));635 user.put("as", rs.getString("accountstatus"));636 user.put("comment", rs.getString("comment"));637 user.put("email", rs.getString("email"));638 639 users.add(user);640 } 641 state.close();642 643 state = conn.createStatement();644 for (HashMap<String, String> user : users) 645 {646 ResultSet gs = state.executeQuery("SELECT role FROM " + ROLES + " WHERE username = '" + user.get("username") + "'");647 conn.commit();648 649 String group = "";650 while (gs.next()) 651 {652 if (!group.equals(""))630 try 631 { 632 Statement state = conn.createStatement(); 633 ResultSet rs = state.executeQuery(sql_find_user); 634 conn.commit(); 635 while (rs.next()) 636 { 637 HashMap<String, String> user = new HashMap<String, String>(); 638 user.put("username", rs.getString("username")); 639 user.put("password", rs.getString("password")); 640 user.put("as", rs.getString("accountstatus")); 641 user.put("comment", rs.getString("comment")); 642 user.put("email", rs.getString("email")); 643 644 users.add(user); 645 } 646 state.close(); 647 648 state = conn.createStatement(); 649 for (HashMap<String, String> user : users) 650 { 651 ResultSet gs = state.executeQuery("SELECT role FROM " + ROLES + " WHERE username = '" + user.get("username") + "'"); 652 conn.commit(); 653 654 String group = ""; 655 while (gs.next()) 653 656 { 654 group += ","; 657 if (!group.equals("")) 658 { 659 group += ","; 660 } 661 group += gs.getString("role"); 655 662 } 656 group += gs.getString("role"); 657 } 658 659 userQueryResult.addUserTerm(user.get("username"), user.get("password"), group, user.get("as"), user.get("comment"), user.get("email")); 660 } 661 state.close(); 663 664 userQueryResult.addUserTerm(user.get("username"), user.get("password"), group, user.get("as"), user.get("comment"), user.get("email")); 665 } 666 state.close(); 667 } 668 catch (Exception ex) 669 { 670 ex.printStackTrace(); 671 } 662 672 663 673 if (userQueryResult.getSize() > 0)
Note:
See TracChangeset
for help on using the changeset viewer.