1. DB 연동 관련 Driver 추가
2. DB 연동 후 데이터 출력 test 파일 제작
This commit is contained in:
@@ -7,8 +7,9 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class BasicDao {
|
||||
private String driver = "com.mysql.jdbc.Driver";
|
||||
private String url = "jdbc:mysql://@110.35.119.108:3307:hospital_DB";
|
||||
private String driver = "org.mariadb.jdbc.Driver";
|
||||
//private String url = "jdbc:mysql://@110.35.119.108:3307:hospital_DB";
|
||||
private String url="jdbc:mariadb://110.35.119.108:3307/hospital_DB";
|
||||
private String user = "mes";
|
||||
private String password = "Mestkdrhdghldmlth1!";
|
||||
protected Connection conn;
|
||||
|
||||
@@ -18,12 +18,8 @@ public class BoardDao extends BasicDao {
|
||||
|
||||
while(this.rs.next()) {
|
||||
BoardVo vo = new BoardVo();
|
||||
vo.u_ID(this.rs.getInt("u_ID"));
|
||||
vo.setWriter(this.rs.getString("writer"));
|
||||
vo.setwDate(this.rs.getDate("wDate"));
|
||||
vo.setTitle(this.rs.getString("title"));
|
||||
vo.setContent(this.rs.getString("content"));
|
||||
vo.setHit(this.rs.getInt("hit"));
|
||||
vo.setu_ID(this.rs.getString("u_ID"));
|
||||
|
||||
list.add(vo);
|
||||
}
|
||||
} catch (SQLException var3) {
|
||||
@@ -35,17 +31,11 @@ public class BoardDao extends BasicDao {
|
||||
|
||||
public BoardVo select(BoardVo vo) {
|
||||
try {
|
||||
int boardId = vo.getBoardId();
|
||||
this.psmt = this.conn.prepareStatement("SELECT * FROM BOARD WHERE boardId = ?");
|
||||
this.psmt.setInt(1, boardId);
|
||||
this.psmt = this.conn.prepareStatement("SELECT * FROM user_tbl");
|
||||
this.rs = this.psmt.executeQuery();
|
||||
if (this.rs.next()) {
|
||||
vo.setWriter(this.rs.getString("writer"));
|
||||
vo.setwDate(this.rs.getDate("wDate"));
|
||||
vo.setTitle(this.rs.getString("title"));
|
||||
vo.setContent(this.rs.getString("content"));
|
||||
vo.setHit(this.rs.getInt("hit"));
|
||||
this.hitCountUp(this.rs.getInt("boardId"));
|
||||
vo.setu_ID(this.rs.getString("u_ID"));
|
||||
vo.setWriter(rs.getString("u_name"));
|
||||
}
|
||||
} catch (SQLException var3) {
|
||||
var3.printStackTrace();
|
||||
@@ -76,7 +66,6 @@ public class BoardDao extends BasicDao {
|
||||
|
||||
try {
|
||||
this.psmt = this.conn.prepareStatement("update board set content = ? where boardId = ?");
|
||||
this.psmt.setInt(1, vo.getBoardId());
|
||||
this.psmt.setString(2, vo.getContent());
|
||||
n = this.psmt.executeUpdate();
|
||||
} catch (SQLException var4) {
|
||||
@@ -91,7 +80,6 @@ public class BoardDao extends BasicDao {
|
||||
|
||||
try {
|
||||
this.psmt = this.conn.prepareStatement("delete from board where boardId = ?");
|
||||
this.psmt.setInt(1, vo.getBoardId());
|
||||
n = this.psmt.executeUpdate();
|
||||
} catch (SQLException var4) {
|
||||
var4.printStackTrace();
|
||||
|
||||
@@ -22,14 +22,6 @@ public class BoardVo {
|
||||
this.writer = writer;
|
||||
}
|
||||
|
||||
public int getBoardId() {
|
||||
return this.boardId;
|
||||
}
|
||||
|
||||
public void setBoardId(int boardId) {
|
||||
this.boardId = boardId;
|
||||
}
|
||||
|
||||
public Date getwDate() {
|
||||
return this.wDate;
|
||||
}
|
||||
@@ -62,8 +54,12 @@ public class BoardVo {
|
||||
this.hit = hit;
|
||||
}
|
||||
|
||||
public void u_ID(String u_ID) {
|
||||
public String getu_ID() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
return this.u_ID;
|
||||
}
|
||||
|
||||
public void setu_ID(String u_ID) {
|
||||
this.u_ID = u_ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,11 @@ public class BoardViewCommand implements Command {
|
||||
}
|
||||
|
||||
public String exec(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
BoardDao dao = new BoardDao();
|
||||
BoardVo vo = new BoardVo();
|
||||
vo = dao.select(vo);
|
||||
request.setAttribute("print", vo);
|
||||
|
||||
return "boardView.jsp";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
<table class="table table-dark">
|
||||
<tr>
|
||||
<th>작성자</th>
|
||||
<td>${board.writer}</td>
|
||||
<td>${print.writer}</td>
|
||||
<th>작성일자</th>
|
||||
<td>${board.wDate}</td>
|
||||
<td>${print.u_ID}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>제목</th>
|
||||
|
||||
Reference in New Issue
Block a user