<% /*============================================================================================== * Project Title : lovehb(ÇѸ¶À½¿¬¼ö¿ø) * File Name : csnot03_ok.jsp * Include : * Used DB Table : notice * Used Class : * Description : °Ô½ÃÆÇ µî·Ï ó¸® * Programmer : °­ÁÖ¿ë * First Write : 2010.04.29 * Last Update : ==============================================================================================*/ %> <%@ page contentType="text/html;charset=euc-kr" %> <%@ include file="/include/in_Import.jsp" %> <%@ include file="/include/in_Function.jsp" %> <% int PageAuth = 1; %> <%! 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()); } } %> <% myUpload.initialize(pageContext); myUpload.upload(); String cmd = request.getParameter("cmd"); System.out.println("cmd : " + cmd); String spage = request.getParameter("spage"); String keytype = request.getParameter("keytype"); String keyword = request.getParameter("keyword"); String file_gubun = request.getParameter("file_gubun1"); String no = sutil.toNullStr(request.getParameter("no")); System.out.println("no : " + no); String password = sutil.toNullStr(request.getParameter("password")); String subject = sutil.toNullStr(request.getParameter("subject")); String name = sutil.toNullStr(request.getParameter("wr_name")); String content = sutil.convertWEBtoDB(sutil.toNullStr(request.getParameter("contents"))); String file_nm = ""; if(spage == null) spage = "1"; if(no == null || no == "") no = "0"; if(cmd == null) cmd = ""; if(keytype == null || keytype.equals("")) keytype = "subject"; if(keyword == null || keyword.equals("")) keyword = ""; int iPage = Integer.parseInt(spage); subject = sutil.toEucKr(subject); name = sutil.toEucKr(name); content = sutil.toEucKr(content); Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; Statement stmt = null; String query = null; int i_rtn = 0; int seq_no = Integer.parseInt(no); try { conn = DriverManager.getConnection("jdbc:postgresql:hanmaum", "postgres", ""); if(cmd.equals("U")) { String query_insert = "UPDATE NOTICE SET SUBJECT = ?, NAME = ?, CONTENTS = ? WHERE NO = ?"; pstmt = conn.prepareStatement(query_insert); pstmt.setString(1, subject); pstmt.setString(2, name); pstmt.setString(3, content); pstmt.setInt(4, seq_no); i_rtn = pstmt.executeUpdate(); } else if(cmd.equals("D")||cmd.equals("DD")) {// º»±Û »èÁ¦ String query_insert = "SELECT COUNT(NO) FROM LOG_IN WHERE NO = ? "; pstmt = conn.prepareStatement(query_insert); pstmt.setInt(1, seq_no); //pstmt.setString(2, password); rs = pstmt.executeQuery(); if(rs != null && rs.next()) { i_rtn = rs.getInt(1); } if(i_rtn > 0) { if(cmd.equals("D")){ query_insert = "DELETE FROM NOTICE WHERE NO = ?"; }else{ query_insert = "DELETE FROM NOTICE_RPL WHERE NO = ?"; } pstmt = conn.prepareStatement(query_insert); pstmt.setInt(1, seq_no); i_rtn = pstmt.executeUpdate(); } } else if(cmd.equals("R")) {// ´äº¯µî·Ï String query_insert = "INSERT INTO NOTICE_RPL (NO, CONTENTS, REG_DT) VALUES (?, ?, now())"; pstmt = conn.prepareStatement(query_insert); pstmt.setInt(1, seq_no); pstmt.setString(2, content); i_rtn = pstmt.executeUpdate(); } else if(cmd.equals("RU")) {//´äº¯¼öÁ¤ String query_insert = "UPDATE NOTICE_RPL SET CONTENTS = ?, REG_DT = now() WHERE NO = ?"; pstmt = conn.prepareStatement(query_insert); pstmt.setString(1, content); pstmt.setInt(2, seq_no); i_rtn = pstmt.executeUpdate(); } else if(cmd.equals("I")) {//±Û µî·Ï stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT NEXTVAL('PUBLIC.NITICE_NO_SEQ')"); int seqNO = 0;//µî·Ï¿¡¸¸ ¾²´Â º¯¼ö while(rs.next()) { seqNO = rs.getInt(1); } String query_insert = " INSERT INTO LOG_IN (NO, PASSWORD) VALUES (?, ?) "; pstmt = conn.prepareStatement(query_insert); pstmt.setInt(1, seqNO); pstmt.setString(2, password); i_rtn = pstmt.executeUpdate(); pstmt.close(); query_insert = " INSERT INTO NOTICE (NO, SUBJECT, NAME, CONTENTS, REG_DT, FILE_NAME, STATE, VIEW_CNT) "; query_insert += " VALUES (?, ?, ?, ?, NOW(), ?, '2', 0)"; pstmt = conn.prepareStatement(query_insert); pstmt.setInt(1, seqNO); pstmt.setString(2, subject); pstmt.setString(3, name); pstmt.setString(4, content); pstmt.setString(5, file_nm); i_rtn = pstmt.executeUpdate(); } pstmt.close(); conn.close(); if (i_rtn > 0) { %> <% } else { %> <% } if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); if (conn != null) conn.close(); } catch (Exception e) { out.println("JSP >> Slight Exception in /CS/csqa03_ok.jsp : " + e.toString()); %> <% } finally { if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); if (conn != null) conn.close(); } %>