%@ page contentType="text/html;charset=euc-kr" %>
<%@ include file="/include/in_Import.jsp" %>
<%@ include file="/include/in_Function.jsp" %>
<%!
static {
try {
new kr.co.slight.jinhae.pool.JDCConnectionDriver("org.postgresql.Driver","jdbc:postgresql:jinhae","postgres","");
} catch(Exception e) {
System.out.println("
JDCConnectionDriver Error : " + e.toString());
}
}
%>
<%
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
int totalCnt = 0; //±ÛÀÇ ÃÑ °¹¼ö
try {
StringBuffer query = new StringBuffer();
StringBuffer query_cnt = new StringBuffer();
query_cnt.append("select count(*) ");
query_cnt.append(" from news ");
query_cnt.append(" limit 1 ");
query.append("select case when length(subject) > 20 then substring(subject,1,30)||'...' else subject end as subject,no,reg_dt ");
query.append(" from news ");
query.append(" order by no desc ");
query.append(" limit 4 " );
System.out.println("query_cnt : " + query_cnt);
System.out.println("query : " + query);
conn = DriverManager.getConnection("jdbc:jdc:jdcpool");
stmt = conn.createStatement();
rs = stmt.executeQuery(query_cnt.toString());
while ( rs.next() ) {
totalCnt = rs.getInt(1);
}
System.out.println("totalCnt : " + totalCnt);
rs.close();
rs = stmt.executeQuery(query.toString());
%>
Untitled Document
<%@ include file="/include/in_Bottom.jsp" %>
<%
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
if ( rs != null ) rs.close();
if ( stmt != null ) stmt.close();
if ( conn != null ) conn.close();
}
%>