JSP 디비 컨넥트

<%@ page language=”java” contentType=”text/html; charset=EUC-KR”
pageEncoding=”EUC-KR”%>
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=EUC-KR”>
<title>Insert title here</title>
</head>
<body>
<table width=”550″ border=”1″>
<%@ page import = “java.sql.*” %>
<%

Connection conn = null;
//String sql = null;
PreparedStatement pstmt = null;
ResultSet rs = null;

try
{
String url1 = “jdbc:sqlserver://localhost:1433;databaseName=IBE_Basic_Code;user=user01;password=password01;”;

conn = DriverManager.getConnection(url1);

String sql = “select top 100 * from IBE_AIRLINE”;
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();

while(rs.next())
{
String id = rs.getString(“country_code”);
String passwd = rs.getString(“airline_english”);
String name = rs.getString(“airline_japan”);
String time = rs.getString(“airline_korean”);
%>
<tr>
<td width=”100″> <%=id%> </td>
<td width=”100″> <%=passwd%> </td>
<td width=”100″> <%=name%> </td>
<td width=”250″> <%=time%> </td>
</tr>

<%
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(rs != null)
try{rs.close();}catch(SQLException sqle){}
if(pstmt != null)
try{pstmt.close();}catch(SQLException sqle){}
if(conn != null)
try{conn.close();}catch(SQLException sqle){}
}
%>
</table>
</body>
</html>