{"id":459,"date":"2018-08-20T19:08:31","date_gmt":"2018-08-20T10:08:31","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=459"},"modified":"2020-08-13T09:53:23","modified_gmt":"2020-08-13T00:53:23","slug":"459","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=459","title":{"rendered":"\uc790\ubc14 \ub514\ube44 \uc5f0\uacb0"},"content":{"rendered":"<p><a href=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB_01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-461\" src=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB_01.jpg\" alt=\"\" width=\"738\" height=\"533\" srcset=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB_01.jpg 738w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB_01-300x217.jpg 300w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><\/a><a href=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-460\" src=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB-1024x755.jpg\" alt=\"\" width=\"600\" height=\"442\" srcset=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB-1024x755.jpg 1024w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB-300x221.jpg 300w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB-768x566.jpg 768w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/javaDB.jpg 1156w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><strong>JAVA<\/strong><\/p>\n<pre class=\"lang:java decode:true \">package javaDB;\r\nimport java.sql.*;\r\nimport com.microsoft.sqlserver.jdbc.*;\r\n\r\npublic class test {\r\n\r\npublic static void main(String[] args) {\r\n\t\t\r\n\t\t\/\/ Declare the JDBC objects.\r\n\t\tConnection con = null;\r\n\t\tCallableStatement cstmt = null;\r\n\t\tResultSet rs = null;\r\n\t\t\r\n\t\ttry {\r\n\t\t\t\/\/ Establish the connection. \r\n\t\t\tSQLServerDataSource ds = new SQLServerDataSource();\r\n\t\t\t\r\n\t\t\t\/\/ds.setIntegratedSecurity(true);\r\n\t\t\tds.setServerName(\"localhost\");\r\n\t\t\tds.setPortNumber(1433); \r\n\t\t\tds.setDatabaseName(\"WSP_IBE\");\r\n\t\t\tds.setUser(\"user01\");\r\n\t\t\tds.setPassword(\"password01\");\r\n\t\t\tcon = ds.getConnection();\r\n\t\t\t \r\n\t        \t\/\/ Execute a stored procedure that returns some data.\r\n            \t\tcstmt = con.prepareCall(\"{call dbo.uspGetAircraft()}\");\r\n            \t\t\/\/cstmt.setInt(1, 50);\r\n            \t\trs = cstmt.executeQuery();\r\n\r\n\t        \t\/\/ Iterate through the data in the result set and display it.\r\n\t        \twhile (rs.next()) {\r\n\t            \t\tSystem.out.println(\"aircraft_code: \" + rs.getString(\"aircraft_code\"));\r\n\t            \t\tSystem.out.println(\"aircraft_english: \" + rs.getString(\"aircraft_english\"));\r\n\t            \t\tSystem.out.println();\r\n\t        \t}\r\n\t        }\r\n\t        \r\n\t\t\/\/ Handle any errors that may have occurred.\r\n\t    \tcatch (Exception e) {\r\n\t    \t\te.printStackTrace();\r\n\t    \t}\r\n\r\n\t   \tfinally {\r\n\t    \t\tif (rs != null) try { rs.close(); } catch(Exception e) {}\r\n\t    \t\tif (cstmt != null) try { cstmt.close(); } catch(Exception e) {}\r\n\t    \t\tif (con != null) try { con.close(); } catch(Exception e) {}\r\n\t    \t}\r\n\t}\r\n}<\/pre>\n<p><strong>JSP mysql<\/strong><\/p>\n<pre class=\"lang:java decode:true \" >&lt;%@ page language=\"java\" contentType=\"text\/html; charset=UTF-8\" pageEncoding=\"UTF-8\"%&gt;\r\n&lt;%@ page import=\"java.sql.*\" %&gt; \r\n \r\n&lt;html&gt; \r\n&lt;head&gt; \r\n&lt;title&gt;Connection with mysql database&lt;\/title&gt; \r\n&lt;\/head&gt; \r\n&lt;body&gt;\r\n&lt;h1&gt;Connection status &lt;\/h1&gt;\r\n\r\n&lt;table&gt;\r\n\r\n&lt;%\r\nString connectionURL = \"jdbc:mysql:\/\/localhost:3306\/IBE?characterEncoding=UTF-8&amp;serverTimezone=UTC\"; \r\n\r\nConnection connection = null; \r\nPreparedStatement pstmt = null;\r\nResultSet rs = null;\r\n\r\ntry{\r\n\tClass.forName(\"com.mysql.jdbc.Driver\").newInstance(); \r\n\tconnection = DriverManager.getConnection(connectionURL, \"user02\", \"user99\");\r\n    \r\n    String query =\"SELECT \ufeffairline_code,airline_korean FROM IBE.Airlines where \ufeffairline_code = ?\";\r\n    \/\/String query =\"SELECT \ufeffairline_code,airline_korean FROM IBE.Airlines\";\r\n    \r\n    pstmt = connection.prepareStatement(query); \r\n    pstmt.setString(1,\"OZ\");\r\n       \t\t\r\n    rs = pstmt.executeQuery();\r\n    \r\n    while(rs.next()){\t\r\n    \tString airline_code = rs.getString(\"\ufeffairline_code\");\r\n    \tString airline_korean = rs.getString(\"airline_korean\"); \r\n%&gt;\r\n\t \t&lt;tr&gt;\r\n\t\t\t&lt;td width=\"100\"&gt;&lt;%=airline_code%&gt;&lt;\/td&gt;\r\n\t\t\t&lt;td width=\"100\"&gt;&lt;%=airline_korean%&gt;&lt;\/td&gt;\r\n\t\t&lt;\/tr&gt;\t\r\n&lt;%\r\n    }\r\n}\r\ncatch(Exception ex){\r\n\tout.println(ex.toString());\r\n}finally{\r\n\tif(rs != null) try{rs.close();}catch(SQLException ex){}           \r\n\tif(pstmt != null) try{pstmt.close();}catch(SQLException ex){}   \r\n\tif(connection != null) try{connection.close();}catch(SQLException ex){}\r\n}\r\n\r\n%&gt;\r\n\r\n&lt;\/table&gt;\r\n\r\n&lt;\/body&gt; \r\n&lt;\/html&gt;<\/pre>\n<p><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/MySQL_jsp02.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/MySQL_jsp02.jpg\" alt=\"\" width=\"619\" height=\"280\" class=\"alignnone size-full wp-image-759\" srcset=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/MySQL_jsp02.jpg 619w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2018\/08\/MySQL_jsp02-300x136.jpg 300w\" sizes=\"auto, (max-width: 619px) 100vw, 619px\" \/><\/a><\/p>\n<p>jsp paramerer<\/p>\n<pre class=\"lang:java decode:true \" >&lt;%@ page language=\"java\" contentType=\"text\/html; charset=UTF-8\" pageEncoding=\"UTF-8\"%&gt;\r\n&lt;%@ page import = \"java.sql.DriverManager\" %&gt;\r\n&lt;%@ page import = \"java.sql.Connection\" %&gt;\r\n&lt;%@ page import = \"java.sql.PreparedStatement\" %&gt;\r\n&lt;%@ page import = \"java.sql.ResultSet\" %&gt;\r\n&lt;%@ page import = \"java.sql.SQLException\" %&gt;\r\n\r\n&lt;%\r\nString connectionURL = \"jdbc:mysql:\/\/localhost:3306\/IBE?characterEncoding=UTF-8&amp;serverTimezone=UTC\"; \r\n\r\nConnection connection = null; \r\nPreparedStatement pstmt = null;\r\nResultSet rs = null;\r\n\r\nString code = request.getParameter(\"code\"); \/\/Code\r\nif(code == null) code=\"\";\r\n\r\nString Decode = code;\r\n\r\ntry{\r\n\tif(code.length()==2){\r\n\t\tClass.forName(\"com.mysql.jdbc.Driver\").newInstance(); \r\n\t\tconnection = DriverManager.getConnection(connectionURL, \"user02\", \"user99\");\r\n\t    \r\n\t    String query =\"SELECT \ufeffairline_code,airline_korean FROM IBE.Airlines where \ufeffairline_code = ? LIMIT 0, 1\";\r\n\t    \r\n\t    pstmt = connection.prepareStatement(query); \r\n\t    pstmt.setString(1,code);\r\n\t       \t\t\r\n\t    rs = pstmt.executeQuery();\r\n\t    \r\n\t\t    while(rs.next()){\r\n\t\t    \tDecode = rs.getString(\"airline_korean\");\r\n\t\t    }\r\n\t   \r\n\t\t    out.println(Decode);\r\n\t   \r\n    }else\t\r\n    \tout.println(code);\r\n\t\r\n}\r\ncatch(Exception ex){\r\n\tout.println(ex.toString());\r\n}finally{\r\n\tif(rs != null) try{rs.close();}catch(SQLException ex){}           \r\n\tif(pstmt != null) try{pstmt.close();}catch(SQLException ex){}   \r\n\tif(connection != null) try{connection.close();}catch(SQLException ex){}\r\n}\r\n%&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>JAVA package javaDB; import java.sql.*; import com.microsoft.sqlserver.jdbc.*; public class test { public static void main(String[] args) { \/\/ Declare the JDBC objects. Connection con = null; CallableStatement cstmt = null; ResultSet rs = null; try { \/\/ Establish the connection. SQLServerDataSource ds = new SQLServerDataSource(); \/\/ds.setIntegratedSecurity(true); ds.setServerName(&#8220;localhost&#8221;); ds.setPortNumber(1433); ds.setDatabaseName(&#8220;WSP_IBE&#8221;); ds.setUser(&#8220;user01&#8221;); ds.setPassword(&#8220;password01&#8221;); con = ds.getConnection(); \/\/\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=459\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"class_list":["post-459","post","type-post","status-publish","format-standard","hentry","category-java"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=459"}],"version-history":[{"count":10,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/459\/revisions"}],"predecessor-version":[{"id":791,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/459\/revisions\/791"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}