<%@ include file="/include/in_Import.jsp" %> <%@ include file="/include/in_Function.jsp" %> <%@ page contentType="text/html;charset=euc-kr" %> <% String textfield = request.getParameter("textfield"); textfield = sutil.toEucKr(textfield); if(textfield == null) textfield = ""; %> <%! static { try { new kr.co.slight.jinhae.pool.JDCConnectionDriver("org.postgresql.Driver","jdbc:postgresql:hanmaum","postgres",""); } catch(Exception e) { System.out.println("

JDCConnectionDriver Error : " + e.toString()); } } %> <% /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ SESSION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ String spage = request.getParameter("spage"); if (spage == null) spage = "1"; int iPage = Integer.parseInt(spage); int totalCnt = 0; //±ÛÀÇ ÃÑ °¹¼ö int totalPage; //ÃÑ ÆäÀÌÁö °¹¼ö int pageSize = 10; //ÇÑÆäÀÌÁö¿¡ º¸¿©ÁÙ ±ÛÀÇ ÃÖ´ë °¹¼ö int blockSize = 10; //ÇÑ È­¸é¿¡ º¸¿©ÁÙ ÃÖ´ë ÆäÀÌÁö °¹¼ö int blockPage; //ÇÑ È­¸é¿¡ º¸¿©Áö´Â ÆäÀÌÁö Áß Ã¹¹ø° ÆäÀÌÁö ¹øÈ£ int start_no = (iPage-1)*pageSize + 1; //ÇØ´ç ÆäÀÌÁöÀÇ Ã¹¹ø° row number int end_no = iPage*pageSize; //ÇØ´ç ÆäÀÌÁöÀÇ ¸¶Áö¸· row number(ÃÖ´ë°ª) Connection conn = null; Statement stmt = null; ResultSet rs = null; ResultSet rtList = null; try { StringBuffer query = new StringBuffer(); StringBuffer query_cnt = new StringBuffer(); query_cnt.append("select count(*) from zip_code"); if(textfield != null && !textfield.equals("")) { query_cnt.append(" where address like '%"+ textfield +"%' "); } else { query_cnt.append(" where 1 = 0 "); } query.append("select * from zip_code where address like '%"+ textfield +"%'"); query.append(" limit ").append(pageSize).append(" offset ").append(start_no-1); conn = DriverManager.getConnection("jdbc:jdc:jdcpool"); stmt = conn.createStatement(); rs = stmt.executeQuery(query_cnt.toString()); while ( rs.next() ) { totalCnt = rs.getInt(1); } rs.close(); totalPage = ((int) (totalCnt - 1)/pageSize ) + 1; blockPage = ((int) (iPage -1)/blockSize ) * blockSize + 1; rtList = stmt.executeQuery(query.toString()); %> ¿ìÆí¹øÈ£ °Ë»ö

ã°íÀÚ ÇÏ´Â ÁÖ¼ÒÀÇ µ¿/À¾/¸é À̸§À» ÀÔ·ÂÇϼ¼¿ä.
 
µ¿(À¾/¸é)
 
<% if (totalCnt > 0) { int i = totalCnt; int no = 0; String postNo = ""; String address = ""; String detail = ""; while (rtList.next()) { postNo = rtList.getString("zip_code"); address = rtList.getString("address"); detail = rtList.getString("detail"); %> <% } } else { %> <% } %>
<%= postNo.substring(0, 3) %> - <%= postNo.substring(3, 6) %>  <%= address %> <%=detail%>
ÁÖ¼Ò°¡ ¾ø½À´Ï´Ù.
<% //ÀÌÀü ÆäÀÌÁö if ( iPage == 1 ) { %> <% } else { %> <% } // ÆäÀÌÁö Loop int loopSize = Math.min(blockPage + blockSize, totalPage + 1); for ( int j=blockPage; j [<%=j%>] <% } else { %> [<%=j%>] <% } } /*----------------------------------------- ´ÙÀ½ ÆäÀÌÁö -----------------------------------------*/ if ( iPage == totalPage ) { %> <% } else { %> <% } %>

<% if ( rs != null ) rs.close(); if ( stmt != null ) stmt.close(); if ( conn != null ) conn.close(); } catch (Exception e) { if ( rs != null ) rs.close(); if ( stmt != null ) stmt.close(); if ( conn != null ) conn.close(); // ¿¡·¯ÆäÀÌÁö·Î À̵¿............ out.println("JSP >> Exception : " + e.toString()); } %>