1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import = "java.sql.DriverManager" %> <%@ page import = "java.sql.Connection" %> <%@ page import = "java.sql.PreparedStatement" %> <%@ page import = "java.sql.ResultSet" %> <%@ page import = "java.sql.SQLException" %> <% String connectionURL = "jdbc:mysql://***.***.***.***:3306/IBE?characterEncoding=UTF-8&serverTimezone=UTC"; Connection connection = null; PreparedStatement pstmt = null; ResultSet rs = null; String code = request.getParameter("code"); //Code if(code == null) code=""; String Decode = code; try{ if(code.length()==2){ Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection(connectionURL, "****user", "*********"); String query ="SELECT airline_code,airline_korean FROM IBE.Airlines where airline_code = ? LIMIT 0, 1"; pstmt = connection.prepareStatement(query); pstmt.setString(1,code); rs = pstmt.executeQuery(); while(rs.next()){ Decode = rs.getString("airline_korean"); } out.println(Decode); }else out.println(code); } catch(Exception ex){ out.println(ex.toString()); }finally{ if(rs != null) try{rs.close();}catch(SQLException ex){} if(pstmt != null) try{pstmt.close();}catch(SQLException ex){} if(connection != null) try{connection.close();}catch(SQLException ex){} } %> |
댓글