이론적인 설명은 없습니다. 어차피 안읽을거 다알아요..


(1) 톰캣 서버 -> context.xml로 가서 설정해준다(Resource).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<Context>
 
    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
 
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--t
    <Manager pathname="" />
    -->
    
    <Resource auth="Container" 
              name="jdbc/Portfolio" 
              driverClassName="com.mysql.jdbc.Driver" 
              type="javax.sql.DataSource" 
              url="jdbc:mysql://localhost:3306/jsp" 
              username="root" //<-보통이거
              password="비밀번호입력" 
              loginTimeout="10" 
              maxActive="50" 
              maxIdle="20"
              maxWait="5000" 
              testOnBorrow="true" />
</Context>    
cs


(2) 아래와 같이 dao에서 이용해줍니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public void album3(BoardAlbumDTOIn ALdto ) throws SQLException
{
    Connection con = DBCP.getConnection(); //커넥션풀연결
    String sql = "insert into album3 set link=?, path=?,albumtype=?";
    PreparedStatement pstm = con.prepareStatement(sql);
    pstm.setInt(1, ALdto.getLink()); //물음표에 순서대로 값넣기
    pstm.setString(2, ALdto.getPicpath());
    pstm.setString(3, ALdto.getAlbumType());
    
    pstm.executeUpdate(); //insert, update문은 executeUpdate입니다.
    
    pstm.close();
    con.close();
    
        
}
 
cs


'jsp' 카테고리의 다른 글

[jsp] dto 이용하기  (0) 2017.09.27
[jsp] 한글깨짐 설정  (0) 2017.09.27
[jsp] servlet doget dopost 받기  (0) 2017.09.27
[jsp] session 사용하기  (0) 2017.09.27
[jsp] servlet sendReDirect,forward  (0) 2017.09.27

+ Recent posts