{"action":"created","comment":{"url":"https://api.github.com/repos/jelem/capella/pulls/comments/166314516","pull_request_review_id":94359014,"id":166314516,"diff_hunk":"@@ -0,0 +1,149 @@\n+package com.hillel;\n+\n+import java.sql.Connection;\n+import java.sql.DriverManager;\n+import java.sql.ResultSet;\n+import java.sql.SQLException;\n+import java.sql.Statement;\n+import java.util.Scanner;\n+\n+\n+public class Main {\n+\n+  public static void main(String[] args) {\n+\n+    Scanner scanner = new Scanner(System.in, \"UTF-8\");\n+    System.out.println(\"Enter password\");\n+    String password = scanner.nextLine();\n+\n+    Connection connection;\n+    try {\n+      connection = DriverManager\n+          .getConnection(\"jdbc:mysql://localhost:3306/bookstore?serverTimezone=UTC&useSSL=false\",\n+              \"root\",\n+              password);\n+    } catch (SQLException exception) {\n+      exception.printStackTrace();\n+      return;\n+    }\n+\n+    System.out.println(\"Books:\");\n+    printBooks(connection);\n+    System.out.println();\n+\n+    System.out.println(\"Authors that younger then 50 years:\");\n+    printAuthors50YearsYounger(connection);\n+    System.out.println();\n+\n+    System.out.println(\"10 most expensive books:\");\n+    printTenExpensiveBooks(connection);\n+    System.out.println();\n+\n+    System.out.println(\"Books that Sergey Bendas have bought:\");\n+    printCustomerBooks(connection);\n+    System.out.println();\n+\n+    System.out.println(\"Total price of books of each author:\");\n+    printTotalPrice(connection);\n+    System.out.println();\n+\n+  }\n+\n+  private static void printTotalPrice(Connection connection) {\n+    String sql = \"SELECT a.author_name, sum(b.price) as total_price \"\n+        + \"FROM authors a \"\n+        + \"INNER JOIN books b \"\n+        + \"ON a.id = b.author_id \"\n+        + \"GROUP BY a.id\";\n+\n+    try (Statement statement = connection.createStatement(); ResultSet resultSet = statement\n+        .executeQuery(sql)) {\n+      while (resultSet.next()) {\n+        String authorName = resultSet.getString(\"a.author_name\");\n+        int totalPrice = resultSet.getInt(\"total_price\");\n+        System.out.println(authorName + \" - \" + totalPrice);\n+      }\n+    } catch (Exception exception) {\n+      exception.printStackTrace();\n+    }\n+  }\n+\n+  private static void printCustomerBooks(Connection connection) {\n+    String sql = \"SELECT b.book_name \"\n+        + \"FROM customers c \"\n+        + \"INNER JOIN selling s \"\n+        + \"ON c.id = s.customer_id \"\n+        + \"INNER JOIN books b \"\n+        + \"ON s.book_id = b.id \"\n+        + \"WHERE c.customer_name = 'Сергей Бендас'\";","path":"task_25/sergey.bendas/src/main/java/com/hillel/Main.java","position":78,"original_position":78,"commit_id":"703269ca810a48cd4dae15564405e888967bb528","original_commit_id":"703269ca810a48cd4dae15564405e888967bb528","user":{"login":"parkhomenko","id":3454949,"avatar_url":"https://avatars1.githubusercontent.com/u/3454949?v=4","gravatar_id":"","url":"https://api.github.com/users/parkhomenko","html_url":"https://github.com/parkhomenko","followers_url":"https://api.github.com/users/parkhomenko/followers","following_url":"https://api.github.com/users/parkhomenko/following{/other_user}","gists_url":"https://api.github.com/users/parkhomenko/gists{/gist_id}","starred_url":"https://api.github.com/users/parkhomenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkhomenko/subscriptions","organizations_url":"https://api.github.com/users/parkhomenko/orgs","repos_url":"https://api.github.com/users/parkhomenko/repos","events_url":"https://api.github.com/users/parkhomenko/events{/privacy}","received_events_url":"https://api.github.com/users/parkhomenko/received_events","type":"User","site_admin":false},"body":"You can use \"?\" to add parameters in the request as we did in the class.","created_at":"2018-02-06T14:22:01Z","updated_at":"2018-02-06T14:22:01Z","html_url":"https://github.com/jelem/capella/pull/103#discussion_r166314516","pull_request_url":"https://api.github.com/repos/jelem/capella/pulls/103","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/jelem/capella/pulls/comments/166314516"},"html":{"href":"https://github.com/jelem/capella/pull/103#discussion_r166314516"},"pull_request":{"href":"https://api.github.com/repos/jelem/capella/pulls/103"}}},"pull_request":{"url":"https://api.github.com/repos/jelem/capella/pulls/103","id":166982340,"html_url":"https://github.com/jelem/capella/pull/103","diff_url":"https://github.com/jelem/capella/pull/103.diff","patch_url":"https://github.com/jelem/capella/pull/103.patch","issue_url":"https://api.github.com/repos/jelem/capella/issues/103","number":103,"state":"open","locked":false,"title":"Task 25","user":{"login":"seregabendas","id":33154214,"avatar_url":"https://avatars2.githubusercontent.com/u/33154214?v=4","gravatar_id":"","url":"https://api.github.com/users/seregabendas","html_url":"https://github.com/seregabendas","followers_url":"https://api.github.com/users/seregabendas/followers","following_url":"https://api.github.com/users/seregabendas/following{/other_user}","gists_url":"https://api.github.com/users/seregabendas/gists{/gist_id}","starred_url":"https://api.github.com/users/seregabendas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seregabendas/subscriptions","organizations_url":"https://api.github.com/users/seregabendas/orgs","repos_url":"https://api.github.com/users/seregabendas/repos","events_url":"https://api.github.com/users/seregabendas/events{/privacy}","received_events_url":"https://api.github.com/users/seregabendas/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-03T21:50:05Z","updated_at":"2018-02-06T14:22:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8d95f07d276f2e3ff0ef0e3af524f7fbd8d5cf92","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/jelem/capella/pulls/103/commits","review_comments_url":"https://api.github.com/repos/jelem/capella/pulls/103/comments","review_comment_url":"https://api.github.com/repos/jelem/capella/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jelem/capella/issues/103/comments","statuses_url":"https://api.github.com/repos/jelem/capella/statuses/703269ca810a48cd4dae15564405e888967bb528","head":{"label":"seregabendas:master","ref":"master","sha":"703269ca810a48cd4dae15564405e888967bb528","user":{"login":"seregabendas","id":33154214,"avatar_url":"https://avatars2.githubusercontent.com/u/33154214?v=4","gravatar_id":"","url":"https://api.github.com/users/seregabendas","html_url":"https://github.com/seregabendas","followers_url":"https://api.github.com/users/seregabendas/followers","following_url":"https://api.github.com/users/seregabendas/following{/other_user}","gists_url":"https://api.github.com/users/seregabendas/gists{/gist_id}","starred_url":"https://api.github.com/users/seregabendas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seregabendas/subscriptions","organizations_url":"https://api.github.com/users/seregabendas/orgs","repos_url":"https://api.github.com/users/seregabendas/repos","events_url":"https://api.github.com/users/seregabendas/events{/privacy}","received_events_url":"https://api.github.com/users/seregabendas/received_events","type":"User","site_admin":false},"repo":{"id":110016111,"name":"capella","full_name":"seregabendas/capella","owner":{"login":"seregabendas","id":33154214,"avatar_url":"https://avatars2.githubusercontent.com/u/33154214?v=4","gravatar_id":"","url":"https://api.github.com/users/seregabendas","html_url":"https://github.com/seregabendas","followers_url":"https://api.github.com/users/seregabendas/followers","following_url":"https://api.github.com/users/seregabendas/following{/other_user}","gists_url":"https://api.github.com/users/seregabendas/gists{/gist_id}","starred_url":"https://api.github.com/users/seregabendas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seregabendas/subscriptions","organizations_url":"https://api.github.com/users/seregabendas/orgs","repos_url":"https://api.github.com/users/seregabendas/repos","events_url":"https://api.github.com/users/seregabendas/events{/privacy}","received_events_url":"https://api.github.com/users/seregabendas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/seregabendas/capella","description":null,"fork":true,"url":"https://api.github.com/repos/seregabendas/capella","forks_url":"https://api.github.com/repos/seregabendas/capella/forks","keys_url":"https://api.github.com/repos/seregabendas/capella/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seregabendas/capella/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seregabendas/capella/teams","hooks_url":"https://api.github.com/repos/seregabendas/capella/hooks","issue_events_url":"https://api.github.com/repos/seregabendas/capella/issues/events{/number}","events_url":"https://api.github.com/repos/seregabendas/capella/events","assignees_url":"https://api.github.com/repos/seregabendas/capella/assignees{/user}","branches_url":"https://api.github.com/repos/seregabendas/capella/branches{/branch}","tags_url":"https://api.github.com/repos/seregabendas/capella/tags","blobs_url":"https://api.github.com/repos/seregabendas/capella/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seregabendas/capella/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seregabendas/capella/git/refs{/sha}","trees_url":"https://api.github.com/repos/seregabendas/capella/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seregabendas/capella/statuses/{sha}","languages_url":"https://api.github.com/repos/seregabendas/capella/languages","stargazers_url":"https://api.github.com/repos/seregabendas/capella/stargazers","contributors_url":"https://api.github.com/repos/seregabendas/capella/contributors","subscribers_url":"https://api.github.com/repos/seregabendas/capella/subscribers","subscription_url":"https://api.github.com/repos/seregabendas/capella/subscription","commits_url":"https://api.github.com/repos/seregabendas/capella/commits{/sha}","git_commits_url":"https://api.github.com/repos/seregabendas/capella/git/commits{/sha}","comments_url":"https://api.github.com/repos/seregabendas/capella/comments{/number}","issue_comment_url":"https://api.github.com/repos/seregabendas/capella/issues/comments{/number}","contents_url":"https://api.github.com/repos/seregabendas/capella/contents/{+path}","compare_url":"https://api.github.com/repos/seregabendas/capella/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seregabendas/capella/merges","archive_url":"https://api.github.com/repos/seregabendas/capella/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seregabendas/capella/downloads","issues_url":"https://api.github.com/repos/seregabendas/capella/issues{/number}","pulls_url":"https://api.github.com/repos/seregabendas/capella/pulls{/number}","milestones_url":"https://api.github.com/repos/seregabendas/capella/milestones{/number}","notifications_url":"https://api.github.com/repos/seregabendas/capella/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seregabendas/capella/labels{/name}","releases_url":"https://api.github.com/repos/seregabendas/capella/releases{/id}","deployments_url":"https://api.github.com/repos/seregabendas/capella/deployments","created_at":"2017-11-08T18:43:45Z","updated_at":"2017-11-08T18:43:47Z","pushed_at":"2018-02-03T21:49:10Z","git_url":"git://github.com/seregabendas/capella.git","ssh_url":"git@github.com:seregabendas/capella.git","clone_url":"https://github.com/seregabendas/capella.git","svn_url":"https://github.com/seregabendas/capella","homepage":null,"size":631,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jelem:master","ref":"master","sha":"b6e49588f011a2f5bd3ba3af5bb0fb16ff8fc3f8","user":{"login":"jelem","id":24527420,"avatar_url":"https://avatars2.githubusercontent.com/u/24527420?v=4","gravatar_id":"","url":"https://api.github.com/users/jelem","html_url":"https://github.com/jelem","followers_url":"https://api.github.com/users/jelem/followers","following_url":"https://api.github.com/users/jelem/following{/other_user}","gists_url":"https://api.github.com/users/jelem/gists{/gist_id}","starred_url":"https://api.github.com/users/jelem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelem/subscriptions","organizations_url":"https://api.github.com/users/jelem/orgs","repos_url":"https://api.github.com/users/jelem/repos","events_url":"https://api.github.com/users/jelem/events{/privacy}","received_events_url":"https://api.github.com/users/jelem/received_events","type":"Organization","site_admin":false},"repo":{"id":109975323,"name":"capella","full_name":"jelem/capella","owner":{"login":"jelem","id":24527420,"avatar_url":"https://avatars2.githubusercontent.com/u/24527420?v=4","gravatar_id":"","url":"https://api.github.com/users/jelem","html_url":"https://github.com/jelem","followers_url":"https://api.github.com/users/jelem/followers","following_url":"https://api.github.com/users/jelem/following{/other_user}","gists_url":"https://api.github.com/users/jelem/gists{/gist_id}","starred_url":"https://api.github.com/users/jelem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelem/subscriptions","organizations_url":"https://api.github.com/users/jelem/orgs","repos_url":"https://api.github.com/users/jelem/repos","events_url":"https://api.github.com/users/jelem/events{/privacy}","received_events_url":"https://api.github.com/users/jelem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jelem/capella","description":null,"fork":false,"url":"https://api.github.com/repos/jelem/capella","forks_url":"https://api.github.com/repos/jelem/capella/forks","keys_url":"https://api.github.com/repos/jelem/capella/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jelem/capella/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jelem/capella/teams","hooks_url":"https://api.github.com/repos/jelem/capella/hooks","issue_events_url":"https://api.github.com/repos/jelem/capella/issues/events{/number}","events_url":"https://api.github.com/repos/jelem/capella/events","assignees_url":"https://api.github.com/repos/jelem/capella/assignees{/user}","branches_url":"https://api.github.com/repos/jelem/capella/branches{/branch}","tags_url":"https://api.github.com/repos/jelem/capella/tags","blobs_url":"https://api.github.com/repos/jelem/capella/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jelem/capella/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jelem/capella/git/refs{/sha}","trees_url":"https://api.github.com/repos/jelem/capella/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jelem/capella/statuses/{sha}","languages_url":"https://api.github.com/repos/jelem/capella/languages","stargazers_url":"https://api.github.com/repos/jelem/capella/stargazers","contributors_url":"https://api.github.com/repos/jelem/capella/contributors","subscribers_url":"https://api.github.com/repos/jelem/capella/subscribers","subscription_url":"https://api.github.com/repos/jelem/capella/subscription","commits_url":"https://api.github.com/repos/jelem/capella/commits{/sha}","git_commits_url":"https://api.github.com/repos/jelem/capella/git/commits{/sha}","comments_url":"https://api.github.com/repos/jelem/capella/comments{/number}","issue_comment_url":"https://api.github.com/repos/jelem/capella/issues/comments{/number}","contents_url":"https://api.github.com/repos/jelem/capella/contents/{+path}","compare_url":"https://api.github.com/repos/jelem/capella/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jelem/capella/merges","archive_url":"https://api.github.com/repos/jelem/capella/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jelem/capella/downloads","issues_url":"https://api.github.com/repos/jelem/capella/issues{/number}","pulls_url":"https://api.github.com/repos/jelem/capella/pulls{/number}","milestones_url":"https://api.github.com/repos/jelem/capella/milestones{/number}","notifications_url":"https://api.github.com/repos/jelem/capella/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jelem/capella/labels{/name}","releases_url":"https://api.github.com/repos/jelem/capella/releases{/id}","deployments_url":"https://api.github.com/repos/jelem/capella/deployments","created_at":"2017-11-08T12:50:04Z","updated_at":"2018-01-24T16:38:14Z","pushed_at":"2018-02-06T14:20:34Z","git_url":"git://github.com/jelem/capella.git","ssh_url":"git@github.com:jelem/capella.git","clone_url":"https://github.com/jelem/capella.git","svn_url":"https://github.com/jelem/capella","homepage":null,"size":629,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":14,"open_issues":5,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jelem/capella/pulls/103"},"html":{"href":"https://github.com/jelem/capella/pull/103"},"issue":{"href":"https://api.github.com/repos/jelem/capella/issues/103"},"comments":{"href":"https://api.github.com/repos/jelem/capella/issues/103/comments"},"review_comments":{"href":"https://api.github.com/repos/jelem/capella/pulls/103/comments"},"review_comment":{"href":"https://api.github.com/repos/jelem/capella/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jelem/capella/pulls/103/commits"},"statuses":{"href":"https://api.github.com/repos/jelem/capella/statuses/703269ca810a48cd4dae15564405e888967bb528"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"parkhomenko"}}