Advertisement
Guest User

Untitled

a guest
Aug 29th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public class Application implements RequestHandler<Object, Boolean> {
  2. private Logger logger = Logger.getLogger(Application.class);
  3. public Boolean handleRequest(Object object, Context context) {
  4. try {
  5. Class.forName("com.mysql.jdbc.Driver");
  6. logger.info("Calling DriverManager.getConnection()");
  7. Connection con = DriverManager.getConnection(
  8. "jdbc:mysql://...endpoint...defaultdb",
  9. "awsops",
  10. "..."
  11. );
  12. Statement stmt = con.createStatement();
  13. logger.info("Test Started!");
  14. ResultSet result = stmt.executeQuery("SELECTn" +
  15. " last_name, COUNT(*)n" +
  16. "FROMn" +
  17. " usersn" +
  18. "GROUP BYn" +
  19. " last_namen" +
  20. "HAVING COUNT(*) > 1");
  21. if (result.next()) {
  22. logger.info(result.getString("last_name"));
  23. }
  24. return true;
  25. } catch (Exception e) {
  26. logger.info(e.getLocalizedMessage());
  27. }
  28. return false;
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement