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 52 53 54 55 56 57 58 59 60 61 62 63 64 |
<%@ 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> |