DBCP

커넥션문 , 사용하지 않는(불필요한) 커넥션은 알아서 close



DAO.java 에서 driver, url, uid, pwd, 입력 대신



Oracle 8i, 9i & 10g ( http://tomcat.apache.org/tomcat-8.0-doc/jndi-datasource-examples-howto.html#Oracle_8i,_9i_&_10g )

1. Context configuration

<Resource name="jdbc/myoracle" auth="Container"

              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"

              url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"

              username="scott" password="tiger" maxTotal="20" maxIdle="10"

              maxWaitMillis="-1"/>


eclipse>servers -> server.xml

95: <Context docBase="ad" path="/ad" reloadable="true" source="org.eclipse.jst.jee.server:ad"/>


to

<Context docBase="ad" path="/ad" reloadable="true" source="org.eclipse.jst.jee.server:ad">

<Resource name="jdbc/myoracle" auth="Container"

              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"

              url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"

              username="scott" password="tiger" maxTotal="20" maxIdle="10"

              maxWaitMillis="-1"/>

</Context>


<Resource name="jdbc/xe" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"

     url="jdbc:oracle:thin:@127.0.0.1:1521:xe" username="oraclejava7" password="oracle5678" maxTotal="20" maxIdle="10" maxWaitMillis="-1"/>







MySQL DBCP Example ( http://tomcat.apache.org/tomcat-8.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example )


<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"

      maxTotal="100" maxIdle="30" maxWaitMillis="10000"

      username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"

      url="jdbc:mysql://localhost:3306/javatest"/>


</Context>

3. web.xml configuration



insert server.xml


<Context docBase="ad" path="/ad" reloadable="true" source="org.eclipse.jst.jee.server:ad">

<Resource name="jdbc/myoracle" auth="Container"

              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"

              url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"

              username="scott" password="tiger" maxTotal="20" maxIdle="10"

              maxWaitMillis="-1"/>

<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"

       maxTotal="100" maxIdle="30" maxWaitMillis="10000"

       username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"

       url="jdbc:mysql://localhost:3306/javatest"/>


</Context>

</Context>



후  DAO.java 에 javax.sql.DataSource 임포트

DataSource ds = null; // DBCP 커넥션풀 연결 레퍼런스 추가

'Web Develop.' 카테고리의 다른 글

mybatis insert/update/delete/select 결과 값  (0) 2017.11.30
DBCP  (0) 2014.09.19

+ Recent posts