{"action":"created","comment":{"url":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/comments/23871561","id":23871561,"diff_hunk":"@@ -0,0 +1,114 @@\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+\n+public class MyDataAccess {\n+\n+\tprivate String _usuario=\"root\";\n+\tprivate String _pwd= \"greiscol\";\n+\tprivate static String _bd=\"high-school\";\n+\tstatic String _url = \"jdbc:mysql://localhost/\"+_bd;\n+\tprivate Connection conn = null;\n+\t\n+\tpublic MyDataAccess() {\n+\t\t\n+\t\ttry{\n+\t\t\tClass.forName(\"com.mysql.jdbc.Connection\");\n+\t\t\tconn = (Connection)DriverManager.getConnection(_url, _usuario, _pwd);\n+\t\t\tif(conn != null)\n+\t\t\t{\n+\t\t\t\tSystem.out.println(\"Conexi-n a base de datos \"+_url+\" . . . Ok\");\n+\t\t\t}\n+\t\t}\n+\t\tcatch(SQLException ex)\n+\t\t{\n+\t\t\tSystem.out.println(\"Hubo un problema al intentar conecarse a la base de datos\"+_url);\n+\t\t}\n+\t\tcatch(ClassNotFoundException ex)\n+\t\t{\n+\t\t\tSystem.out.println(ex);\n+\t\t}\t\t\n+\t}\n+\t\n+\tpublic ResultSet getQuery(String _query)\n+\t{\n+\t\tStatement state = null;\n+\t\tResultSet resultado = null;\n+\t\ttry{\n+\t\t\tstate = (Statement) conn.createStatement();\n+\t\t\tresultado = state.executeQuery(_query);\n+\t\t}\n+\t\tcatch(SQLException e)\n+\t\t{\n+\t\t\te.printStackTrace();\n+\t\t\n+\t\t}\n+\t\treturn resultado;\n+\t}\n+\tpublic void listGivenStudent(int studentNum){\n+\t\tResultSet result;\n+\t\tString student;\n+\t\tString course;\n+\t\tString finalNote;\n+\t\t\n+\t\tresult = this.getQuery(\"SELECT CONCAT(student_last_name,',',student_first_name) as Student, course.course_name as Course, \"\n+\t\t\t\t+ \"final FROM (course INNER JOIN student_assist_course ON course.course_name=student_assist_course.Course_name) \"\n+\t\t\t\t+ \"INNER JOIN student ON student_assist_course.Student_registration_number=student.registration_number \"\n+\t\t\t\t+ \"WHERE student_registration_number= \"+ studentNum\n+\t\t\t\t+ \" ORDER BY course.course_name ASC, final ASC;\");\n+\t\tSystem.out.println(\"Student     \"+\"Course             \"+\"Final\");\n+\t\ttry {\n+\t\t\twhile(result.next()){\n+\t\t\t\tstudent= result.getString(\"Student\");\n+\t\t\t\tcourse= result.getString(\"Course\");\n+\t\t\t\tfinalNote= result.getString(\"final\");\n+\t\t\t\tSystem.out.println(student+\"   \"+course+\"             \"+finalNote);\n+\t\t\t}\n+\t\t} catch (SQLException e) {\n+\t\t\t// TODO Auto-generated catch block\n+\t\t\te.printStackTrace();\n+\t\t}\n+\t}\n+\tpublic void listGivenCourse(String courseName){\n+\t\tResultSet result;\n+\t    result = this.getQuery(\"SELECT course.course_name as Course, \"\n+\t    \t\t+ \"CONCAT(last_name,',',first_name) as Teacher, \"\n+\t    \t\t+ \"CONCAT(student_last_name,',',student_first_name) as Student \"\n+\t    \t\t+ \"FROM ((teacher INNER JOIN course ON teacher.teacher_id=course.Teacher_id) \"\n+\t    \t\t+ \"INNER JOIN student_assist_course ON course.course_name=student_assist_course.Course_name) \"\n+\t    \t\t+ \"INNER JOIN student ON student_assist_course.Student_registration_number=student.registration_number \"\n+\t    \t\t+ \"WHERE course.course_name= '\"+courseName+\"' \" \n+\t    \t\t+ \"ORDER BY course.course_name ASC, student_last_name ASC;\");\n+\t\ttry {\n+\t    \tboolean first=true;\n+\t    \twhile(result.next()){\n+\t    \t\tif(first){\n+\t\t\tString course= result.getString(\"Course\");\n+\t\t\tString teacher= result.getString(\"Teacher\");\n+\t\t\tSystem.out.println(\"Course: \"+ course);\n+\t\t\tSystem.out.println(\"Teacher: \"+ teacher);\n+\t\t\tSystem.out.println(\"Students:\");\n+\t    \tfirst=false;}\n+\t    \t\tString student= result.getString(\"Student\");\n+\t    \t\tSystem.out.println(\"\t\"+student);\n+\t    \t\t}\n+\t\t} catch (SQLException e) {\n+\t\t\t// TODO Auto-generated catch block\n+\t\t\te.printStackTrace();\n+\t\t}\n+\t}\n+\tpublic void setQuery(String _query){\n+\n+\t\tStatement state = null;\n+\t\t\n+\t\ttry{\t\t\t\n+\t\t\tstate=(Statement) conn.createStatement();\n+\t\t\tstate.execute(_query);\n+\n+         } catch (SQLException e){\n+            e.printStackTrace();\n+       }\n+\t}","path":"sql/MyDataAccess.java","position":113,"original_position":113,"commit_id":"7c2c007459cd89a911481469cc45bf2c4da56c4a","original_commit_id":"7c2c007459cd89a911481469cc45bf2c4da56c4a","user":{"login":"scalderon","id":6900343,"avatar_url":"https://avatars.githubusercontent.com/u/6900343?v=3","gravatar_id":"","url":"https://api.github.com/users/scalderon","html_url":"https://github.com/scalderon","followers_url":"https://api.github.com/users/scalderon/followers","following_url":"https://api.github.com/users/scalderon/following{/other_user}","gists_url":"https://api.github.com/users/scalderon/gists{/gist_id}","starred_url":"https://api.github.com/users/scalderon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalderon/subscriptions","organizations_url":"https://api.github.com/users/scalderon/orgs","repos_url":"https://api.github.com/users/scalderon/repos","events_url":"https://api.github.com/users/scalderon/events{/privacy}","received_events_url":"https://api.github.com/users/scalderon/received_events","type":"User","site_admin":false},"body":"[High] You should close the connection.","created_at":"2015-01-30T20:53:45Z","updated_at":"2015-01-30T20:53:45Z","html_url":"https://github.com/samantatorrez/java-bootcamp/pull/3#discussion_r23871561","pull_request_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/comments/23871561"},"html":{"href":"https://github.com/samantatorrez/java-bootcamp/pull/3#discussion_r23871561"},"pull_request":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/3","id":28252212,"html_url":"https://github.com/samantatorrez/java-bootcamp/pull/3","diff_url":"https://github.com/samantatorrez/java-bootcamp/pull/3.diff","patch_url":"https://github.com/samantatorrez/java-bootcamp/pull/3.patch","issue_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues/3","number":3,"state":"open","locked":false,"title":"Update topic 5","user":{"login":"samantatorrez","id":10515518,"avatar_url":"https://avatars.githubusercontent.com/u/10515518?v=3","gravatar_id":"","url":"https://api.github.com/users/samantatorrez","html_url":"https://github.com/samantatorrez","followers_url":"https://api.github.com/users/samantatorrez/followers","following_url":"https://api.github.com/users/samantatorrez/following{/other_user}","gists_url":"https://api.github.com/users/samantatorrez/gists{/gist_id}","starred_url":"https://api.github.com/users/samantatorrez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samantatorrez/subscriptions","organizations_url":"https://api.github.com/users/samantatorrez/orgs","repos_url":"https://api.github.com/users/samantatorrez/repos","events_url":"https://api.github.com/users/samantatorrez/events{/privacy}","received_events_url":"https://api.github.com/users/samantatorrez/received_events","type":"User","site_admin":false},"body":"topic 5\r\nkey points 1,2,3,4,5,8","created_at":"2015-01-29T03:59:20Z","updated_at":"2015-01-30T20:53:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e3f7e58b99cc9b15301f60169f8b0b2049ca9d0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/3/commits","review_comments_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/3/comments","review_comment_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/comments/{number}","comments_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues/3/comments","statuses_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/statuses/7c2c007459cd89a911481469cc45bf2c4da56c4a","head":{"label":"samantatorrez:branch-5","ref":"branch-5","sha":"7c2c007459cd89a911481469cc45bf2c4da56c4a","user":{"login":"samantatorrez","id":10515518,"avatar_url":"https://avatars.githubusercontent.com/u/10515518?v=3","gravatar_id":"","url":"https://api.github.com/users/samantatorrez","html_url":"https://github.com/samantatorrez","followers_url":"https://api.github.com/users/samantatorrez/followers","following_url":"https://api.github.com/users/samantatorrez/following{/other_user}","gists_url":"https://api.github.com/users/samantatorrez/gists{/gist_id}","starred_url":"https://api.github.com/users/samantatorrez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samantatorrez/subscriptions","organizations_url":"https://api.github.com/users/samantatorrez/orgs","repos_url":"https://api.github.com/users/samantatorrez/repos","events_url":"https://api.github.com/users/samantatorrez/events{/privacy}","received_events_url":"https://api.github.com/users/samantatorrez/received_events","type":"User","site_admin":false},"repo":{"id":29252040,"name":"java-bootcamp","full_name":"samantatorrez/java-bootcamp","owner":{"login":"samantatorrez","id":10515518,"avatar_url":"https://avatars.githubusercontent.com/u/10515518?v=3","gravatar_id":"","url":"https://api.github.com/users/samantatorrez","html_url":"https://github.com/samantatorrez","followers_url":"https://api.github.com/users/samantatorrez/followers","following_url":"https://api.github.com/users/samantatorrez/following{/other_user}","gists_url":"https://api.github.com/users/samantatorrez/gists{/gist_id}","starred_url":"https://api.github.com/users/samantatorrez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samantatorrez/subscriptions","organizations_url":"https://api.github.com/users/samantatorrez/orgs","repos_url":"https://api.github.com/users/samantatorrez/repos","events_url":"https://api.github.com/users/samantatorrez/events{/privacy}","received_events_url":"https://api.github.com/users/samantatorrez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samantatorrez/java-bootcamp","description":"Java Bootcamp","fork":true,"url":"https://api.github.com/repos/samantatorrez/java-bootcamp","forks_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/forks","keys_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/teams","hooks_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/hooks","issue_events_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues/events{/number}","events_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/events","assignees_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/assignees{/user}","branches_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/branches{/branch}","tags_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/tags","blobs_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/refs{/sha}","trees_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/statuses/{sha}","languages_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/languages","stargazers_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/stargazers","contributors_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/contributors","subscribers_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/subscribers","subscription_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/subscription","commits_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/commits{/sha}","git_commits_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/commits{/sha}","comments_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/comments{/number}","issue_comment_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues/comments/{number}","contents_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/contents/{+path}","compare_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/merges","archive_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/downloads","issues_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues{/number}","pulls_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls{/number}","milestones_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/milestones{/number}","notifications_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/labels{/name}","releases_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/releases{/id}","created_at":"2015-01-14T15:55:26Z","updated_at":"2015-01-13T23:17:00Z","pushed_at":"2015-01-29T03:56:05Z","git_url":"git://github.com/samantatorrez/java-bootcamp.git","ssh_url":"git@github.com:samantatorrez/java-bootcamp.git","clone_url":"https://github.com/samantatorrez/java-bootcamp.git","svn_url":"https://github.com/samantatorrez/java-bootcamp","homepage":null,"size":408,"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":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"samantatorrez:master","ref":"master","sha":"23e7ae7bcc526870c23859d61bbf36f5ba2cdc92","user":{"login":"samantatorrez","id":10515518,"avatar_url":"https://avatars.githubusercontent.com/u/10515518?v=3","gravatar_id":"","url":"https://api.github.com/users/samantatorrez","html_url":"https://github.com/samantatorrez","followers_url":"https://api.github.com/users/samantatorrez/followers","following_url":"https://api.github.com/users/samantatorrez/following{/other_user}","gists_url":"https://api.github.com/users/samantatorrez/gists{/gist_id}","starred_url":"https://api.github.com/users/samantatorrez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samantatorrez/subscriptions","organizations_url":"https://api.github.com/users/samantatorrez/orgs","repos_url":"https://api.github.com/users/samantatorrez/repos","events_url":"https://api.github.com/users/samantatorrez/events{/privacy}","received_events_url":"https://api.github.com/users/samantatorrez/received_events","type":"User","site_admin":false},"repo":{"id":29252040,"name":"java-bootcamp","full_name":"samantatorrez/java-bootcamp","owner":{"login":"samantatorrez","id":10515518,"avatar_url":"https://avatars.githubusercontent.com/u/10515518?v=3","gravatar_id":"","url":"https://api.github.com/users/samantatorrez","html_url":"https://github.com/samantatorrez","followers_url":"https://api.github.com/users/samantatorrez/followers","following_url":"https://api.github.com/users/samantatorrez/following{/other_user}","gists_url":"https://api.github.com/users/samantatorrez/gists{/gist_id}","starred_url":"https://api.github.com/users/samantatorrez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samantatorrez/subscriptions","organizations_url":"https://api.github.com/users/samantatorrez/orgs","repos_url":"https://api.github.com/users/samantatorrez/repos","events_url":"https://api.github.com/users/samantatorrez/events{/privacy}","received_events_url":"https://api.github.com/users/samantatorrez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samantatorrez/java-bootcamp","description":"Java Bootcamp","fork":true,"url":"https://api.github.com/repos/samantatorrez/java-bootcamp","forks_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/forks","keys_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/teams","hooks_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/hooks","issue_events_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues/events{/number}","events_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/events","assignees_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/assignees{/user}","branches_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/branches{/branch}","tags_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/tags","blobs_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/refs{/sha}","trees_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/statuses/{sha}","languages_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/languages","stargazers_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/stargazers","contributors_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/contributors","subscribers_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/subscribers","subscription_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/subscription","commits_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/commits{/sha}","git_commits_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/git/commits{/sha}","comments_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/comments{/number}","issue_comment_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues/comments/{number}","contents_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/contents/{+path}","compare_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/merges","archive_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/downloads","issues_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues{/number}","pulls_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls{/number}","milestones_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/milestones{/number}","notifications_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/labels{/name}","releases_url":"https://api.github.com/repos/samantatorrez/java-bootcamp/releases{/id}","created_at":"2015-01-14T15:55:26Z","updated_at":"2015-01-13T23:17:00Z","pushed_at":"2015-01-29T03:56:05Z","git_url":"git://github.com/samantatorrez/java-bootcamp.git","ssh_url":"git@github.com:samantatorrez/java-bootcamp.git","clone_url":"https://github.com/samantatorrez/java-bootcamp.git","svn_url":"https://github.com/samantatorrez/java-bootcamp","homepage":null,"size":408,"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":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/3"},"html":{"href":"https://github.com/samantatorrez/java-bootcamp/pull/3"},"issue":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues/3"},"comments":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/samantatorrez/java-bootcamp/statuses/7c2c007459cd89a911481469cc45bf2c4da56c4a"}}}}