context.xml에 넣는법

jaminyeong·2023년 11월 9일

jsp

목록 보기
2/10

tomcat->documentation10.1->JDBC DataSource->2. Context configuration->resource로 시작하는거

https://tomcat.apache.org/tomcat-10.1-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_2_Example

=>수정!

 <Resource name="dbcp_mysql" auth="Container" type="javax.sql.DataSource"
              maxTotal="100" maxIdle="30" maxWaitMillis="10000"
              username="lmy" password="1234" driverClassName="com.mysql.cj.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/jspdb?userSSL=false&amp;serverTimezone=Asia/Seoul&amp;characterEncoding=UTF-8"/>

2.[3. web.xml configuration] web.xml에

<description>MySQL Test App</description>
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/TestDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
=>변경
    <description>MySQL DB App</description>
    <resource-ref>
        <description>MySQL DB Connection</description>
        <res-ref-name>dbcp_mysql</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
    
   3. Oracle 8i, 9i & 10g
   

<현재 나의 web.xml>

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
       version="4.0">

  <session-config>
      <session-timeout>20</session-timeout>
  </session-config>








  <description>MySQL DB App</description>
  <resource-ref>
      <description>MySQL DB Connection</description>
      <res-ref-name>dbcp_mysql</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>


<context-param>
  <param-name>MySQLDriver</param-name>
  <param-value>com.mysql.cj.jdbc.Driver</param-value>
</context-param>

<context-param>
  <param-name>MySQLURL</param-name>
  <param-value>jdbc:mysql://localhost:3306/jspdb?useSSl=false&amp;serverTimezone=Asia/Seoul&amp;charcterEncoding=UTF-8</param-value>
</context-param>

<context-param>
  <param-name>MySQLId</param-name>
  <param-value>lmy</param-value>
</context-param>

<context-param>
  <param-name>MySQLPwd</param-name>
  <param-value>1234</param-value>
</context-param>

</web-app>

<현재 나의 context.>

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/">
  <Resource name="dbcp_oracle" auth="Container"
            type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
            url="jdbc:oracle:thin:@127.0.0.1:1521:orcl"
            username="lmy" password="1234"
            maxTotal="20" maxIdle="10"
            maxWaitMillis="-1"/>




  <Resource name="dbcp_mysql" auth="Container" type="javax.sql.DataSource"
            maxTotal="100" maxIdle="30" maxWaitMillis="10000"
            username="lmy" password="1234" driverClassName="com.mysql.cj.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/jspdb?userSSL=false&amp;serverTimezone=Asia/Seoul&amp;characterEncoding=UTF-8"/>
</Context>

profile
주니어 개발자 잼미뇽 공부용 기록장

0개의 댓글