개발도구/WAS

Tomcat에서 DBCP 사용

노루아부지 2019. 8. 11. 12:46

Context.xml <Context> 태그 안에 아래 내용 추가

<Resource name=”jdbc/postgres” auth=”Container” //postgres는 임의의 이름
          type=”javax.sql.DataSource”<?xml:namespace prefix = o />
          username=”test”
          password=”test”
          factory=”org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory”
          driverClassName=”org.postgresql.Driver”
          url=”jdbc:postgresql://192.168.10.241:5432/postgres”       //postgres는 임의의 이름
          maxActive=”8” maxIdle=”4”             //숫자는 상황에 맞게
          removeAbandoned=”true”/>

 

Web.xml <web-app>안에 아래 내용 추가

<resource-ref>
   <description>postgresSql Datasource examble</description>
   <res-ref-name>jdbc/postgres</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>

-       Ojdbc14.jar 파일을 다운받아 [tomcat]-[lib]폴더에 넣어준다.

-       (Tomcat 구버전은 commons-collections-3.1.jar, commons-dbcp-1.2.1.jar, commons-pool-1.2.jar 등을 [tomcat] – [lib] 폴더에 넣어주어야 하지만 6.0은 넣어줄 필요가 없다.)

-       Postgresql-버전.jdbc.jar 파일을 lib 폴더에 넣어준다.

728x90

'개발도구 > WAS' 카테고리의 다른 글

Tomcat 시작 시 Class 호출  (0) 2019.08.15
Tocat 6.0 Cotext setting  (0) 2019.08.11
CentOS에 Tomcat 설치  (0) 2019.08.11
tomcat + openssl  (0) 2019.07.31
tomcat port 추가  (0) 2019.07.27
loading