최신글
hyeonga_code
Ajax_Ajax 를 활용한 댓글 구현하기 본문
반응형
- Ajax를 활용한 댓글 구현하기
- 테이블 생성하기
=====
1
2
3
4
5
6
7
8
9
|
CREATE TABLE TABLEMENT (
ID NUMBER(10,0) NOT NULL ENABLE,
NAME VARCHAR2(20) NOT NULL ENABLE,
CONTENT VARCHAR2(4000) NOT NULL ENABLE,
CONSTRAINT TABLEMENT_PK PRIMARY KEY (ID) ENABLE
);
/*
Table TABLEMENT이(가) 생성되었습니다.
*/
|
- 시퀀스 생성하기
=====
1
2
3
4
5
6
7
8
9
10
11
12
|
CREATE SEQUENCE TABLEMENT_SEQ
MINVALUE 1
MAXVALUE 9999999
INCREMENT BY 1
START WITH 1
NOCACHE
NOORDER
NOCYCLE;
/*
Sequence TABLEMENT_SEQ이(가) 생성되었습니다.
*/
|
- webapp > ajaxRe 폴더 생성하기
- webapp > WEB-INF > lib 폴더에 필요한 라이브러리 추가하기
- commons-collections-3.2.10.jar
- commons-dbcp-1.4.jar
- commons-pool-1.6.jar
- ojdbc.jar
- webapp > META-INF > 'context.xml' xml 파일을 생성하기
=====
1
2
3
4
5
6
7
8
9
|
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/myOracle" auth="Container"
driverClassName="oracle.jdbc.driver.OracleDriver"
type="javax.sql.DataSource" url="jdbc:oracle:thin:@localhost:1521:xe"
username="test" password="test" maxTotal="8" maxIdle="10"
maxWaitMillis="-1" />
</Context>
|
- webapp > WEB-INF > web.xml 추가
=====
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
id="WebApp_ID" version="4.0">
<display-name>pro05_JSON</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>default.htm</welcome-file>
</welcome-file-list>
<resource-ref>
<description>ConnectionPool</description>
<res-ref-name>jdbc/myOracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
|
- 필요한 유틸 클래스를 생성합니다.
- src/main/java > util > 'DB.java' 클래스를 생성합니다.
=====
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
26
27
28
29
|
package util;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class DB {
private static DataSource dataSource;
static {
try {
Context init = new InitialContext();
dataSource = (DataSource) init.lookup("java:comp/env/jdbc/myOracle");
} catch (NamingException e) {
e.printStackTrace();
}
}
private DB() {}
public static Connection getConnection() throws SQLException {
return dataSource.getConnection();
}
}
|
반응형
'Ajax' 카테고리의 다른 글
Ajax_XMLHttpRequest 객체를 사용하여 XML 파일을 텍스트 형식으로 표시하기 (0) | 2023.10.25 |
---|---|
Ajax_DOM_XML 응답 생성하기 (0) | 2023.10.21 |
Ajax_DOM_XSL/T를 사용하여 XML을 HTML로 변환하기 (0) | 2023.10.21 |
Ajax_DOM_DOM API를 사용하여 HTML 화면을 변경하기 (0) | 2023.10.20 |
Ajax_DOM_DOM API 를 사용하여 문서 구조 변경하기 (0) | 2023.10.20 |