{"action":"created","comment":{"url":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/comments/89520571","pull_request_review_id":10066197,"id":89520571,"diff_hunk":"@@ -0,0 +1,82 @@\n+package tradehistory;\n+\n+import java.sql.Connection;\n+import java.sql.PreparedStatement;\n+import java.sql.ResultSet;\n+import java.sql.SQLException;\n+\n+/**\n+ * @author Denis Dimitrov <denis.k.dimitrov@gmail.com>\n+ */\n+public class Vendor {\n+    private Connection connection;\n+\n+    public Vendor(Connection connection) {\n+        this.connection = connection;\n+    }\n+\n+    /**\n+     * Updates the values of the table \"vendor\" by \"id\". But before that saves the previous row in another table\n+     * called \"vendorhistory\". You pass the new product values and the id of the old product that will be changed.\n+     *\n+     * @param product new product values\n+     * @return\n+     */\n+    public Product update(Product product) {\n+        try {\n+            String update = \"update vendor set product=?, price=? where id=?\";\n+            PreparedStatement preparedStatement = connection.prepareStatement(update);\n+            preparedStatement.setString(1, product.name);\n+            preparedStatement.setInt(2, product.price);\n+            preparedStatement.setInt(3, product.id);\n+            preparedStatement.executeUpdate();\n+        } catch (SQLException e) {\n+            e.printStackTrace();\n+        }\n+        return null;\n+    }\n+\n+    /**\n+     * Deletes from the table \"vendor\" by the primary key \"id\" after that saves it in the \"vendorhistory\" via trigger;\n+     *\n+     * @param id\n+     * @return\n+     */\n+    public Product delete(int id) {\n+        try {\n+            String update = \"delete from vendor where id=\" + id + \"\";\n+            PreparedStatement preparedStatement = connection.prepareStatement(update);\n+            preparedStatement.executeUpdate();\n+        } catch (SQLException e) {\n+            e.printStackTrace();\n+        }\n+        return null;\n+    }\n+\n+    /**\n+     * Displays the content of the second table \"vendorhistory\" with limit and offset.\n+     *\n+     * @param limit  maximum rows to be displayed\n+     * @param offset number of rows to skip\n+     * @return\n+     */\n+    public Product showHistory(int limit, int offset) {\n+        try {\n+            String showHistory = \"select * from vendorhistory limit \" + limit + \" offset \" + offset + \"\";\n+            PreparedStatement preparedStatement = connection.prepareStatement(showHistory);\n+            ResultSet resultSet = preparedStatement.executeQuery();\n+            while (resultSet.next()) {\n+                String product = resultSet.getString(\"product\");\n+                int id = resultSet.getInt(\"id\");\n+                int price = resultSet.getInt(\"price\");\n+                System.out.println(\"Product: \" + product);\n+                System.out.println(\"ID: \" + id);\n+                System.out.println(\"Price: \" + price);\n+                System.out.println();\n+            }\n+        } catch (SQLException e) {\n+            e.printStackTrace();\n+        }\n+        return null;","path":"src/main/java/tradehistory/Vendor.java","position":80,"original_position":80,"commit_id":"db2c7cd06510b62d424b5a86b51fb5438dbf6d93","original_commit_id":"db2c7cd06510b62d424b5a86b51fb5438dbf6d93","user":{"login":"denisdimitrov","id":18435853,"avatar_url":"https://avatars.githubusercontent.com/u/18435853?v=3","gravatar_id":"","url":"https://api.github.com/users/denisdimitrov","html_url":"https://github.com/denisdimitrov","followers_url":"https://api.github.com/users/denisdimitrov/followers","following_url":"https://api.github.com/users/denisdimitrov/following{/other_user}","gists_url":"https://api.github.com/users/denisdimitrov/gists{/gist_id}","starred_url":"https://api.github.com/users/denisdimitrov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denisdimitrov/subscriptions","organizations_url":"https://api.github.com/users/denisdimitrov/orgs","repos_url":"https://api.github.com/users/denisdimitrov/repos","events_url":"https://api.github.com/users/denisdimitrov/events{/privacy}","received_events_url":"https://api.github.com/users/denisdimitrov/received_events","type":"User","site_admin":false},"body":"I will just make the methods void because it will be faster, however I will make sure to read this.","created_at":"2016-11-24T15:53:53Z","updated_at":"2016-11-24T15:53:53Z","html_url":"https://github.com/clouway-incubator/jdbc/pull/24#discussion_r89520571","pull_request_url":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/comments/89520571"},"html":{"href":"https://github.com/clouway-incubator/jdbc/pull/24#discussion_r89520571"},"pull_request":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/24","id":94620820,"html_url":"https://github.com/clouway-incubator/jdbc/pull/24","diff_url":"https://github.com/clouway-incubator/jdbc/pull/24.diff","patch_url":"https://github.com/clouway-incubator/jdbc/pull/24.patch","issue_url":"https://api.github.com/repos/clouway-incubator/jdbc/issues/24","number":24,"state":"open","locked":false,"title":"JDBC: Product History","user":{"login":"denisdimitrov","id":18435853,"avatar_url":"https://avatars.githubusercontent.com/u/18435853?v=3","gravatar_id":"","url":"https://api.github.com/users/denisdimitrov","html_url":"https://github.com/denisdimitrov","followers_url":"https://api.github.com/users/denisdimitrov/followers","following_url":"https://api.github.com/users/denisdimitrov/following{/other_user}","gists_url":"https://api.github.com/users/denisdimitrov/gists{/gist_id}","starred_url":"https://api.github.com/users/denisdimitrov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denisdimitrov/subscriptions","organizations_url":"https://api.github.com/users/denisdimitrov/orgs","repos_url":"https://api.github.com/users/denisdimitrov/repos","events_url":"https://api.github.com/users/denisdimitrov/events{/privacy}","received_events_url":"https://api.github.com/users/denisdimitrov/received_events","type":"User","site_admin":false},"body":"Updates a product in one table by id and saves the changes in another table. There is a showHistory() method with limit and offset to display the history.","created_at":"2016-11-21T14:04:31Z","updated_at":"2016-11-24T15:53:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b18bf9da6ff84082799da05763e31e3291415a85","assignee":{"login":"EmilGeorgiev","id":5961191,"avatar_url":"https://avatars.githubusercontent.com/u/5961191?v=3","gravatar_id":"","url":"https://api.github.com/users/EmilGeorgiev","html_url":"https://github.com/EmilGeorgiev","followers_url":"https://api.github.com/users/EmilGeorgiev/followers","following_url":"https://api.github.com/users/EmilGeorgiev/following{/other_user}","gists_url":"https://api.github.com/users/EmilGeorgiev/gists{/gist_id}","starred_url":"https://api.github.com/users/EmilGeorgiev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EmilGeorgiev/subscriptions","organizations_url":"https://api.github.com/users/EmilGeorgiev/orgs","repos_url":"https://api.github.com/users/EmilGeorgiev/repos","events_url":"https://api.github.com/users/EmilGeorgiev/events{/privacy}","received_events_url":"https://api.github.com/users/EmilGeorgiev/received_events","type":"User","site_admin":false},"assignees":[{"login":"EmilGeorgiev","id":5961191,"avatar_url":"https://avatars.githubusercontent.com/u/5961191?v=3","gravatar_id":"","url":"https://api.github.com/users/EmilGeorgiev","html_url":"https://github.com/EmilGeorgiev","followers_url":"https://api.github.com/users/EmilGeorgiev/followers","following_url":"https://api.github.com/users/EmilGeorgiev/following{/other_user}","gists_url":"https://api.github.com/users/EmilGeorgiev/gists{/gist_id}","starred_url":"https://api.github.com/users/EmilGeorgiev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EmilGeorgiev/subscriptions","organizations_url":"https://api.github.com/users/EmilGeorgiev/orgs","repos_url":"https://api.github.com/users/EmilGeorgiev/repos","events_url":"https://api.github.com/users/EmilGeorgiev/events{/privacy}","received_events_url":"https://api.github.com/users/EmilGeorgiev/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/24/commits","review_comments_url":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/24/comments","review_comment_url":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clouway-incubator/jdbc/issues/24/comments","statuses_url":"https://api.github.com/repos/clouway-incubator/jdbc/statuses/db2c7cd06510b62d424b5a86b51fb5438dbf6d93","head":{"label":"denisdimitrov:task3","ref":"task3","sha":"db2c7cd06510b62d424b5a86b51fb5438dbf6d93","user":{"login":"denisdimitrov","id":18435853,"avatar_url":"https://avatars.githubusercontent.com/u/18435853?v=3","gravatar_id":"","url":"https://api.github.com/users/denisdimitrov","html_url":"https://github.com/denisdimitrov","followers_url":"https://api.github.com/users/denisdimitrov/followers","following_url":"https://api.github.com/users/denisdimitrov/following{/other_user}","gists_url":"https://api.github.com/users/denisdimitrov/gists{/gist_id}","starred_url":"https://api.github.com/users/denisdimitrov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denisdimitrov/subscriptions","organizations_url":"https://api.github.com/users/denisdimitrov/orgs","repos_url":"https://api.github.com/users/denisdimitrov/repos","events_url":"https://api.github.com/users/denisdimitrov/events{/privacy}","received_events_url":"https://api.github.com/users/denisdimitrov/received_events","type":"User","site_admin":false},"repo":{"id":73807415,"name":"jdbc","full_name":"denisdimitrov/jdbc","owner":{"login":"denisdimitrov","id":18435853,"avatar_url":"https://avatars.githubusercontent.com/u/18435853?v=3","gravatar_id":"","url":"https://api.github.com/users/denisdimitrov","html_url":"https://github.com/denisdimitrov","followers_url":"https://api.github.com/users/denisdimitrov/followers","following_url":"https://api.github.com/users/denisdimitrov/following{/other_user}","gists_url":"https://api.github.com/users/denisdimitrov/gists{/gist_id}","starred_url":"https://api.github.com/users/denisdimitrov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denisdimitrov/subscriptions","organizations_url":"https://api.github.com/users/denisdimitrov/orgs","repos_url":"https://api.github.com/users/denisdimitrov/repos","events_url":"https://api.github.com/users/denisdimitrov/events{/privacy}","received_events_url":"https://api.github.com/users/denisdimitrov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/denisdimitrov/jdbc","description":null,"fork":true,"url":"https://api.github.com/repos/denisdimitrov/jdbc","forks_url":"https://api.github.com/repos/denisdimitrov/jdbc/forks","keys_url":"https://api.github.com/repos/denisdimitrov/jdbc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/denisdimitrov/jdbc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/denisdimitrov/jdbc/teams","hooks_url":"https://api.github.com/repos/denisdimitrov/jdbc/hooks","issue_events_url":"https://api.github.com/repos/denisdimitrov/jdbc/issues/events{/number}","events_url":"https://api.github.com/repos/denisdimitrov/jdbc/events","assignees_url":"https://api.github.com/repos/denisdimitrov/jdbc/assignees{/user}","branches_url":"https://api.github.com/repos/denisdimitrov/jdbc/branches{/branch}","tags_url":"https://api.github.com/repos/denisdimitrov/jdbc/tags","blobs_url":"https://api.github.com/repos/denisdimitrov/jdbc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/denisdimitrov/jdbc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/denisdimitrov/jdbc/git/refs{/sha}","trees_url":"https://api.github.com/repos/denisdimitrov/jdbc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/denisdimitrov/jdbc/statuses/{sha}","languages_url":"https://api.github.com/repos/denisdimitrov/jdbc/languages","stargazers_url":"https://api.github.com/repos/denisdimitrov/jdbc/stargazers","contributors_url":"https://api.github.com/repos/denisdimitrov/jdbc/contributors","subscribers_url":"https://api.github.com/repos/denisdimitrov/jdbc/subscribers","subscription_url":"https://api.github.com/repos/denisdimitrov/jdbc/subscription","commits_url":"https://api.github.com/repos/denisdimitrov/jdbc/commits{/sha}","git_commits_url":"https://api.github.com/repos/denisdimitrov/jdbc/git/commits{/sha}","comments_url":"https://api.github.com/repos/denisdimitrov/jdbc/comments{/number}","issue_comment_url":"https://api.github.com/repos/denisdimitrov/jdbc/issues/comments{/number}","contents_url":"https://api.github.com/repos/denisdimitrov/jdbc/contents/{+path}","compare_url":"https://api.github.com/repos/denisdimitrov/jdbc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/denisdimitrov/jdbc/merges","archive_url":"https://api.github.com/repos/denisdimitrov/jdbc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/denisdimitrov/jdbc/downloads","issues_url":"https://api.github.com/repos/denisdimitrov/jdbc/issues{/number}","pulls_url":"https://api.github.com/repos/denisdimitrov/jdbc/pulls{/number}","milestones_url":"https://api.github.com/repos/denisdimitrov/jdbc/milestones{/number}","notifications_url":"https://api.github.com/repos/denisdimitrov/jdbc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/denisdimitrov/jdbc/labels{/name}","releases_url":"https://api.github.com/repos/denisdimitrov/jdbc/releases{/id}","deployments_url":"https://api.github.com/repos/denisdimitrov/jdbc/deployments","created_at":"2016-11-15T11:32:04Z","updated_at":"2016-08-23T06:51:26Z","pushed_at":"2016-11-24T15:51:55Z","git_url":"git://github.com/denisdimitrov/jdbc.git","ssh_url":"git@github.com:denisdimitrov/jdbc.git","clone_url":"https://github.com/denisdimitrov/jdbc.git","svn_url":"https://github.com/denisdimitrov/jdbc","homepage":null,"size":1329,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"clouway-incubator:denis_dimitrov","ref":"denis_dimitrov","sha":"25ab215aec9c6102d9d71a4888e65d307d33300e","user":{"login":"clouway-incubator","id":10173098,"avatar_url":"https://avatars.githubusercontent.com/u/10173098?v=3","gravatar_id":"","url":"https://api.github.com/users/clouway-incubator","html_url":"https://github.com/clouway-incubator","followers_url":"https://api.github.com/users/clouway-incubator/followers","following_url":"https://api.github.com/users/clouway-incubator/following{/other_user}","gists_url":"https://api.github.com/users/clouway-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/clouway-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clouway-incubator/subscriptions","organizations_url":"https://api.github.com/users/clouway-incubator/orgs","repos_url":"https://api.github.com/users/clouway-incubator/repos","events_url":"https://api.github.com/users/clouway-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/clouway-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":66341183,"name":"jdbc","full_name":"clouway-incubator/jdbc","owner":{"login":"clouway-incubator","id":10173098,"avatar_url":"https://avatars.githubusercontent.com/u/10173098?v=3","gravatar_id":"","url":"https://api.github.com/users/clouway-incubator","html_url":"https://github.com/clouway-incubator","followers_url":"https://api.github.com/users/clouway-incubator/followers","following_url":"https://api.github.com/users/clouway-incubator/following{/other_user}","gists_url":"https://api.github.com/users/clouway-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/clouway-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clouway-incubator/subscriptions","organizations_url":"https://api.github.com/users/clouway-incubator/orgs","repos_url":"https://api.github.com/users/clouway-incubator/repos","events_url":"https://api.github.com/users/clouway-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/clouway-incubator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clouway-incubator/jdbc","description":null,"fork":false,"url":"https://api.github.com/repos/clouway-incubator/jdbc","forks_url":"https://api.github.com/repos/clouway-incubator/jdbc/forks","keys_url":"https://api.github.com/repos/clouway-incubator/jdbc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clouway-incubator/jdbc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clouway-incubator/jdbc/teams","hooks_url":"https://api.github.com/repos/clouway-incubator/jdbc/hooks","issue_events_url":"https://api.github.com/repos/clouway-incubator/jdbc/issues/events{/number}","events_url":"https://api.github.com/repos/clouway-incubator/jdbc/events","assignees_url":"https://api.github.com/repos/clouway-incubator/jdbc/assignees{/user}","branches_url":"https://api.github.com/repos/clouway-incubator/jdbc/branches{/branch}","tags_url":"https://api.github.com/repos/clouway-incubator/jdbc/tags","blobs_url":"https://api.github.com/repos/clouway-incubator/jdbc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clouway-incubator/jdbc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clouway-incubator/jdbc/git/refs{/sha}","trees_url":"https://api.github.com/repos/clouway-incubator/jdbc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clouway-incubator/jdbc/statuses/{sha}","languages_url":"https://api.github.com/repos/clouway-incubator/jdbc/languages","stargazers_url":"https://api.github.com/repos/clouway-incubator/jdbc/stargazers","contributors_url":"https://api.github.com/repos/clouway-incubator/jdbc/contributors","subscribers_url":"https://api.github.com/repos/clouway-incubator/jdbc/subscribers","subscription_url":"https://api.github.com/repos/clouway-incubator/jdbc/subscription","commits_url":"https://api.github.com/repos/clouway-incubator/jdbc/commits{/sha}","git_commits_url":"https://api.github.com/repos/clouway-incubator/jdbc/git/commits{/sha}","comments_url":"https://api.github.com/repos/clouway-incubator/jdbc/comments{/number}","issue_comment_url":"https://api.github.com/repos/clouway-incubator/jdbc/issues/comments{/number}","contents_url":"https://api.github.com/repos/clouway-incubator/jdbc/contents/{+path}","compare_url":"https://api.github.com/repos/clouway-incubator/jdbc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clouway-incubator/jdbc/merges","archive_url":"https://api.github.com/repos/clouway-incubator/jdbc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clouway-incubator/jdbc/downloads","issues_url":"https://api.github.com/repos/clouway-incubator/jdbc/issues{/number}","pulls_url":"https://api.github.com/repos/clouway-incubator/jdbc/pulls{/number}","milestones_url":"https://api.github.com/repos/clouway-incubator/jdbc/milestones{/number}","notifications_url":"https://api.github.com/repos/clouway-incubator/jdbc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clouway-incubator/jdbc/labels{/name}","releases_url":"https://api.github.com/repos/clouway-incubator/jdbc/releases{/id}","deployments_url":"https://api.github.com/repos/clouway-incubator/jdbc/deployments","created_at":"2016-08-23T06:51:26Z","updated_at":"2016-08-23T06:51:26Z","pushed_at":"2016-11-24T15:51:56Z","git_url":"git://github.com/clouway-incubator/jdbc.git","ssh_url":"git@github.com:clouway-incubator/jdbc.git","clone_url":"https://github.com/clouway-incubator/jdbc.git","svn_url":"https://github.com/clouway-incubator/jdbc","homepage":null,"size":1494,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/24"},"html":{"href":"https://github.com/clouway-incubator/jdbc/pull/24"},"issue":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/issues/24"},"comments":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/clouway-incubator/jdbc/statuses/db2c7cd06510b62d424b5a86b51fb5438dbf6d93"}}}}
{"actor":{"display_login":"denisdimitrov"}}