database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
Oracle
Informix
ㆍSybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
Sybase Q&A 2290 게시물 읽기
No. 2290
너무답답해서 글을올립니다.ㅠ
작성자
홍종진(hsk380703)
작성일
2008-09-03 22:05
조회수
10,194

에스큐엘쓰다가 싸이베이스 쓰니깐 용어가 틀려서그런건지 잘안되더라구요..ㅠㅠ

너무답답해서 글을올립니다.   긴글이 될듯한데요.. 게시판소스거든요??

BoardBean.jsp 파일입니다.


package skill;

public class BoardBean {

 private int num;
 private String name;
 private String email;
 private String homepage;
 private String subject;
 private String content;
 private int pos;
 private int depth;
 private String regdate;
 private String pass;
 private int coun;
 private String ip;

 public void setNum(int num) {
  this.num = num;
 }
 public void setName(String name) {
  this.name = name;
 }
 public void setEmail(String email) {
  this.email = email;
 }
 public void setHomepage(String homepage) {
  this.homepage = homepage;
 }
 public void setSubject(String subject) {
  this.subject = subject;
 }
 public void setContent(String content) {
  this.content = content;
 }
 public void setPos(int pos) {
  this.pos = pos;
 }
 public void setDepth(int depth) {
  this.depth = depth;
 }
 public void setRegdate(String regdate) {
  this.regdate = regdate;
 }
 public void setPass(String pass) {
  this.pass = pass;
 }
 public void setCoun(int coun) {
  this.coun = coun;
 }
 public void setIp(String ip) {
  this.ip = ip;
 }

 public int getNum() {
  return num;
 }
 public String getName() {
  return name;
 }
 public String getEmail() {
  return email;
 }
 public String getHomepage() {
  return homepage;
 }
 public String getSubject() {
  return subject;
 }
 public String getContent() {
  return content;
 }
 public int getPos() {
  return pos;
 }
 public int getDepth() {
  return depth;
 }
 public String getRegdate() {
  return regdate;
 }
 public String getPass() {
  return pass;
 }
 public int getCoun() {
  return coun;
 }
 public String getIp() {
  return ip;
 }
}


BoardMgr.jsp 파일입니다.

package skill;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;
import skill.*;

public class BoardMgr {

 private DBConnectionMgr pool = null;

    public BoardMgr() {
    try{
   pool = DBConnectionMgr.getInstance();
    }catch(Exception e){
   System.out.println("Error : 커넥션 가져오기 실패!!");
  }
    }

 public Vector getBoardList(String keyField, String keyWord) {
          Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String strQuery = null;
    Vector boardList = new Vector();
      
    try { 
    con = pool.getConnection();
    stmt = con.createStatement();
    if(keyWord.equals("null") || keyWord.equals("")){
      strQuery = "select * from e_board order by pos asc";
    }else{
      strQuery = "select * from e_board where "
      +keyField+" like '%" + keyWord +"%' order by pos asc";
    }
   rs = stmt.executeQuery(strQuery);
   while (rs.next()) {
   BoardBean tempBean = new BoardBean();

   tempBean.setNum(rs.getInt("num"));
   tempBean.setName(rs.getString("name"));
   tempBean.setEmail(rs.getString("email"));
   tempBean.setHomepage(rs.getString("homepage"));
   tempBean.setSubject(rs.getString("subject"));
   tempBean.setContent(rs.getString("content"));
   tempBean.setPos(rs.getInt("pos"));
   tempBean.setDepth(rs.getInt("depth"));
   tempBean.setRegdate(rs.getString("regdate"));
   tempBean.setPass(rs.getString("pass"));
   tempBean.setCoun(rs.getInt("coun"));
   boardList.addElement(tempBean);
   
   }
    }catch(Exception ex){
    System.out.println("Exception" + ex);
    }finally{
         pool.freeConnection(con,stmt,rs);  
    }
  return boardList;
 }

 public void insertBoard(BoardBean boardBean){
    Connection con = null;
    PreparedStatement pstmt = null;
    upPos();
   
    try {
   con = pool.getConnection();
   String strQuery = "insert into e_board"
     + "(name,email,homepage,subject,content,pos,depth,regdate,pass,coun,ip)"
     + " values(?,?,?,?,?,?,?,NOW(),?,?,?)";
                   
     pstmt = con.prepareStatement(strQuery);
     pstmt.setString(1,boardBean.getName());
     pstmt.setString(2,boardBean.getEmail());
     pstmt.setString(3,boardBean.getHomepage());
     pstmt.setString(4,boardBean.getSubject());
     pstmt.setString(5,boardBean.getContent());
     pstmt.setInt(6,boardBean.getPos());
     pstmt.setInt(7,boardBean.getDepth());
     pstmt.setString(8,boardBean.getPass());
     pstmt.setInt(9,boardBean.getCoun());
     pstmt.setString(10,boardBean.getIp());
     pstmt.executeUpdate();

    }catch(Exception ex) {
    System.out.println("Exception" + ex);
    }finally{
          pool.freeConnection(con,pstmt);   
    }
 }

 public void upPos(){
    Connection con = null;
    Statement stmt = null;
   
    try{
   con = pool.getConnection();
   stmt=con.createStatement();
   String strQuery="update e_board set pos=pos+1";
   stmt.executeUpdate(strQuery);
    }catch(Exception ex) {
    System.out.println("Exception" + ex);
       }finally{
         pool.freeConnection(con,stmt);   
    }
 }

 public BoardBean getBoard(int num) {
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    upCoun(num);
    BoardBean tempBean = new BoardBean();
  
    try {
   con = pool.getConnection();
   String strQuery = "select * from e_board where num = ?";s
   pstmt = con.prepareStatement(strQuery);
   pstmt.setInt(1,num);
   rs = pstmt.executeQuery();
      while (rs.next()) {
   
    tempBean.setNum(rs.getInt("num"));
    tempBean.setName(rs.getString("name"));
    tempBean.setEmail(rs.getString("email"));
    tempBean.setHomepage(rs.getString("homepage"));
    tempBean.setSubject(rs.getString("subject"));
    tempBean.setContent(rs.getString("content"));
    tempBean.setPos(rs.getInt("pos"));
    tempBean.setDepth(rs.getInt("depth"));
    tempBean.setRegdate(rs.getString("regdate"));
    tempBean.setPass(rs.getString("pass"));
    tempBean.setCoun(rs.getInt("coun"));
    tempBean.setIp(rs.getString("ip"));
   }
    }catch(Exception ex) {
     System.out.println("Exception" + ex);
    }finally{
          pool.freeConnection(con,pstmt,rs);  
    }
  return tempBean;
 }

 public void upCoun(int num) {
    Connection con = null;
    PreparedStatement pstmt = null;
  
    try{
   con = pool.getConnection();
   String strQuery="update e_board set coun=coun+1 where num= ?";
   pstmt = con.prepareStatement(strQuery);
   pstmt.setInt(1,num);
   pstmt.executeUpdate();
    }catch(Exception ex) {
   System.out.println("Exception" + ex);
       }finally{
         pool.freeConnection(con,pstmt);   
    }
 }

 public void deleteBoard(int num) { 
    Connection con = null;
    PreparedStatement pstmt = null;
  
    try{
   con = pool.getConnection();
   String strQuery = "delete from e_board where num = ?";
   pstmt = con.prepareStatement(strQuery);
   pstmt.setInt(1,num);
   pstmt.executeUpdate();
    }catch(Exception ex) {
        System.out.println("Exception" + ex);
    }finally{
         pool.freeConnection(con,pstmt);   
    }
 }

 public void updateBoard(BoardBean boardBean){
    Connection con = null;
    PreparedStatement pstmt = null;
  
       try{
   con = pool.getConnection();
   String strQuery = "update e_board set "
       + "name=?,email=?,homepage=?,subject=?,content=?"
       + "where num=?";
     
   pstmt = con.prepareStatement(strQuery);
   pstmt.setString(1,boardBean.getName());
   pstmt.setString(2,boardBean.getEmail());
   pstmt.setString(3,boardBean.getHomepage());
   pstmt.setString(4,boardBean.getSubject());
   pstmt.setString(5,boardBean.getContent());
   pstmt.setInt(6,boardBean.getNum());
   pstmt.executeUpdate();
   }catch(Exception ex) {
   System.out.println("Exception" + ex);
   }finally{
            pool.freeConnection(con,pstmt);   
    }
 }

 public void replyupMyBoard(BoardBean reBoardBean) {
  Connection con = null;
  PreparedStatement pstmt = null;
  
  try{
   con = pool.getConnection();
   int pos = reBoardBean.getPos();
   String strQuery = "update e_board set pos = pos + 1 where pos > ?";
   pstmt = con.prepareStatement(strQuery);
   pstmt.setInt(1,pos);
   pstmt.executeUpdate();
  }catch(Exception ex) {
   System.out.println("Exception" + ex);
  }finally{
         pool.freeConnection(con,pstmt);   
  }
 }

 public void replyMyBoard(BoardBean reBoardBean){
    Connection con = null;
    PreparedStatement pstmt = null;
  
    try{
   con = pool.getConnection();
   int depth = reBoardBean.getDepth() + 1;
   int pos = reBoardBean.getPos()+1;
   String strQuery = "insert into e_board"
       + "(name,email,homepage,subject,content,pos,depth,regdate,pass,coun,ip)"
       + " values (?,?,?,?,?,?,?,NOW(),?,?,?)";
                 
     pstmt = con.prepareStatement(strQuery);
     pstmt.setString(1,reBoardBean.getName());
     pstmt.setString(2,reBoardBean.getEmail());
     pstmt.setString(3,reBoardBean.getHomepage());
     pstmt.setString(4,reBoardBean.getSubject());
     pstmt.setString(5,reBoardBean.getContent());
     pstmt.setInt(6,pos);
     pstmt.setInt(7,depth);
     pstmt.setString(8,reBoardBean.getPass());
     pstmt.setInt(9,reBoardBean.getCoun());
     pstmt.setString(10,reBoardBean.getIp());
     pstmt.executeUpdate();
       
    }catch(Exception ex) {
    System.out.println("Exception" + ex);
    }finally{
          pool.freeConnection(con,pstmt);       
    }
   }
}


Post.jsp 파일입니다.

<%@ page contentType="text/html; charset=EUC-KR" %>
<%@ page import="skill.*,java.util.*"%>

<html>
<head><title>JSPBoard</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<center>
<br><br>
<table width=80% cellspacing=0 cellpadding=3>
 <tr>
  <td bgcolor=84F399 height=25 align=center>글쓰기</td>
 </tr>
</table>
<br>
<table width=80% cellspacing=0 cellpadding=3 align=center>
<form name=post method=post action="PostProc.jsp" >
 <tr>
  <td align=center>
   <table border=0 width=100% align=center>
    <tr>
     <td width=10%>성 명</td>
     <td width=90%><input type=text name=name size=10 maxlength=8></td>
    </tr>
    <tr>
  <td width=10%>E-Mail</td>
  <td width=90%><input type=text name=email size=30 maxlength=30></td>
    </tr>
    <tr>
     <td width=10%>홈페이지</td>
     <td width=90%><input type=text name=homepage size=40 maxlength=30></td>
    </tr>
    <tr>
     <td width=10%>제 목</td>
     <td width=90%><input type=text name=subject size=50 maxlength=30></td>
    </tr>
    <tr>
     <td width=10%>내 용</td>
     <td width=90%><textarea name=content rows=10 cols=50></textarea></td>
    </tr>
    <tr>
     <td width=10%>비밀 번호</td>
     <td width=90% ><input type=password name=pass size=15 maxlength=15></td>
    </tr>
    <tr>
     <td colspan=2><hr size=1></td>
    </tr>
    <tr>
     <td><input type=submit value="등록" >&nbsp;&nbsp;
         <input type=reset value="다시쓰기">&nbsp;&nbsp;
     </td>
    </tr>
    <input type=hidden name=ip value="<%=request.getRemoteAddr()%>" >
   </table>
  </td>
 </tr>
</form>
</table>
</center>
</body>
</html>


PostProc.jsp 파일입니다.

<%@ page contentType="text/html; charset=EUC-KR" %>
<%@ page import="skill.*,java.util.*"%>
<%
  request.setCharacterEncoding("euc-kr");
%>
<jsp:useBean id="myBoard" class="skill.BoardBean" />
<jsp:setProperty name="myBoard" property="*" />
<jsp:useBean id="etri" class="skill.BoardMgr" />
<%
  etri.insertBoard(myBoard);
  response.sendRedirect("List.jsp");
%>


이렇게 했는데 왜 글이 안올라가죠??

List.jsp 파일입니다.

<%@ page contentType="text/html; charset=EUC-KR"%>
<%@ page import="skill.*,java.util.*"%>

<jsp:useBean id="etri" class="skill.BoardMgr" />

<%
  request.setCharacterEncoding("euc-kr");
%>
<%
   int nowPage = 0;
   int nowBlock = 0;
   int totalRecord = 0;
   int numPerPage = 10;     
   int totalPage = 0;      
   int totalBlock = 0;     
   int pagePerBlock =0;   
   int beginPerPage =0;   

   String keyField ="" ;
   String keyWord ="" ;

   Vector boardList;
%>
<%
 
 if(request.getParameter("keyWord") !=null){
   keyWord =request.getParameter("keyWord");
   keyField =request.getParameter("keyField");
  }
  
 if(request.getParameter("reload") !=null){
  if(request.getParameter("reload").equals("true")){
   keyWord ="";
   keyField ="";
   }
 }

 boardList= etri.getBoardList(keyField,keyWord);
 totalRecord = boardList.size();
 numPerPage = 10;
 if (request.getParameter("page") != null) { nowPage= Integer.parseInt(request.getParameter("page")); }
 beginPerPage = nowPage * numPerPage;
 totalPage =(int)Math.ceil((double)totalRecord / numPerPage);
 pagePerBlock = 15;
 if (request.getParameter("nowBlock") != null) {nowBlock = Integer.parseInt(request.getParameter("nowBlock"));}
 totalBlock =(int)Math.ceil((double)totalPage / pagePerBlock);
%>
<html>
<head><title>JSPBoard</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script>
function check() {
     if (document.search.keyWord.value == "")
  {
   alert("검색어를 입력하세요.");
   document.search.keyWord.focus();
   return;
     }
  document.search.submit();
 }

function list(){
 document.list.action="List.jsp";
  document.list.submit();
 }

 function read(value){
 document.read.action="Read.jsp";
 document.read.num.value=value;
 document.read.submit();  
 }

</script>
</head>
<body>
<center><br>
<h2>JSPBoard</h2><br>
<table align=center border=0 width=80%>
 <tr>
  <td align=left >Total : <%=totalRecord%> Articles(<font color=red><%=nowPage+1%>/<%=totalPage%>Pages</font>)</td>
 </tr>
</table>
<table align=center width="80%" border=0 cellspacing=0 cellpadding=3>
 <tr>
  <td align=center colspan=2 >
<%
   if (boardList.isEmpty()) {
%>
등록된 글이 없습니다.
<%  }
   else {
%>
   <table border=0 width=100% cellpadding=2 cellspacing=0>
    <tr align=center bgcolor=#D0D0D0 height=120%>
     <td>번 호</td>
  <td>제 목</td>
  <td>이 름</td>
  <td>날 짜</td>
  <td>조회수</td>
    </tr>
<%
 for (int i = beginPerPage;i < (beginPerPage+numPerPage); i++) {
 if (i==totalRecord) break;

 BoardBean tempBoard = (BoardBean)boardList.elementAt(i);
 String name =tempBoard.getName();
 String subject = tempBoard.getSubject();
 String email = tempBoard.getEmail();
 String regdate = tempBoard.getRegdate();
 int depth = tempBoard.getDepth();
 int num = tempBoard.getNum();
 int coun =tempBoard.getCoun();
%>
    <tr>
     <td align=center><%= totalRecord - i %></td>
     <td>
<%
 if (depth > 0) {
 for (int re = 0; re < depth; re++) {
%>
&nbsp;&nbsp;
<%
  }
   }
%>
      <a href="javascript:read('<%=num%>')"><%= subject %></a>
     </td>
     <td align=center><a href="mailto:<%=email %>"><%= name %></a></td>
     <td align=center><%=regdate%></td>
     <td align=center><%=coun%> </td>
    </tr>
<%
   }
%>

   </table>
<%
   }
%>
  </td>
 </tr>
 <tr>
  <td><br><br></td>
 </tr>
 <tr>
  <td align="left" > Go to Page
<% if(totalRecord !=0){ %>
<% if (nowBlock > 0) {%>
<a href="List.jsp?nowBlock=<%=nowBlock - 1 %>&page=<%=((nowBlock - 1) * pagePerBlock) %>">
이전 <%=pagePerBlock %> 개</a>
<%}%>
:::
<%
for (int i = 0; i < pagePerBlock; i++) { %>
<a href="List.jsp?nowBlock=<%=nowBlock %>&page=<%=(nowBlock*pagePerBlock) + i %>">
<%=(nowBlock * pagePerBlock) + i + 1 %></a>

<% if ((nowBlock * pagePerBlock) + i + 1 == totalPage)  break; %>
<%} %>

:::

<% if (totalBlock > nowBlock + 1) {%>
<a href="List.jsp?nowBlock=<%=nowBlock + 1 %>&page=<%=((nowBlock + 1) * pagePerBlock) %>">
다음 <%=pagePerBlock %>개</a>
<%}%>

<%} %>
  </td>
  <td align=right>
   <a href="Post.jsp" >[글쓰기]</a><a href="javascript:list()">[처음으로]</a>
  </td>
 </tr>
</table><br>
<form action="List.jsp" name="search" method="post">
<table border=0 width=527 align=center cellpadding=4 cellspacing=0 >
 <tr>
  <td align=center valign=bottom>
   <select name="keyField" size=1 >
    <option value="name"> 이 름
    <option value="subject"> 제 목
    <option value="content"> 내 용
   </select>
   <input type="text" size=16 name="keyWord"  value="">
   <input type="button"  value="찾기" onClick="check()">
   <input type="hidden" name="page" value="0">
  </td>
 </tr>
</table>
</form>
<form name="read" method="post">
    <input type="hidden" name="num" value="">
    <input type="hidden" name="page" value="<%=nowPage%>">
    <input type="hidden" name="keyField" value="<%=keyField%>">
    <input type="hidden" name="keyWord" value="<%=keyWord%>">
 </form>
<form name="list" method="post">
 <input type="hidden" name="reload" value="true">
 <input type="hidden" name="page" value="0">
 <input type="hidden" name="nowBlock" value="0">
</form>
</center>
</body>
</html>


왜 등록이안될까요.ㅠㅠㅠㅠㅠㅠ

살려주세요;;;



이 글에 대한 댓글이 총 3건 있습니다.
CREATE TABLE board (
 num                 numeric(5) identity             NOT NULL   ,
 name                varchar(15)          NULL      ,
 email               varchar(30)          NULL      ,
 homepage            varchar(50)          NULL      ,
 subject             varchar(50)          NULL      ,
 content             text                 NULL      ,
 pos                 int              NULL      ,
 depth               smallint          NULL      ,
 regdate             date                 NULL      ,
 pass                varchar(15)          NULL      ,
 coun               smallint          NULL      ,
 ip                  varchar(15)          NULL      ,
 PRIMARY KEY ( num )
);
홍종진(hsk380703)님이 2008-09-03 22:08에 작성한 댓글입니다.

now()를 getdate()로 바꿔보세요.

울랄라님이 2008-09-04 10:00에 작성한 댓글입니다. Edit

혹 autocommit mode가 false로 실행 한것은 아닌가요....

갈매기(갈매기)님이 2008-09-09 14:36에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
2293update 작업..관련 문의 드려요.. [1]
문의..
2008-09-17
7363
2292update 도중 중지 시키면.. ㅠ-ㅠ [2]
문의..
2008-09-16
6924
2291sybase ase 설치후, 서버시작 문의 [1]
카즈머스
2008-09-16
7861
2290너무답답해서 글을올립니다.ㅠ [3]
홍종진
2008-09-03
10194
2289배치파일 만드는 법좀 알려주세요... [1]
송효순
2008-09-03
7044
2288index 에 대해서.[다시 한번만] [5]
경호선
2008-09-03
8114
2287user defind function 보는 방법좀 알려주세요 [2]
초보
2008-09-03
7521
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.019초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다