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