<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>Connection with mysql database</title>
</head>
<body>
<h1>Connection status </h1>
<table>
<%
String connectionURL = "jdbc:mysql://localhost:3306/IBE?characterEncoding=UTF-8&serverTimezone=UTC";
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "user02", "user99");
String query ="SELECT airline_code,airline_korean FROM IBE.Airlines where airline_code = ?";
//String query ="SELECT airline_code,airline_korean FROM IBE.Airlines";
pstmt = connection.prepareStatement(query);
pstmt.setString(1,"OZ");
rs = pstmt.executeQuery();
while(rs.next()){
String airline_code = rs.getString("airline_code");
String airline_korean = rs.getString("airline_korean");
%>
<tr>
<td width="100"><%=airline_code%></td>
<td width="100"><%=airline_korean%></td>
</tr>
<%
}
}
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){}
}
%>
</table>
</body>
</html>