개발/MySQL

[MySQL] MySQL 8.0, Tomcat 9에서 context 설정하기

Monsh 2020. 4. 13. 21:37
반응형
https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_2_Example

위의 reference에서 확인했다.

<Context>

    <!-- maxTotal: Maximum number of database connections in pool.
          Make sure you configure your mysqld max_connections large enough to handle all of your db connections.
          Set to -1 for no limit. -->

    <!-- maxIdle: Maximum number of idle database connections to retain in pool.
          Set to -1 for no limit.
          See also the DBCP 2 documentation on this and the minEvictableIdleTimeMillis configuration parameter.-->

    <!-- maxWaitMillis: Maximum time to wait for a database connection to become available in ms, in this example 10 seconds.
          An Exception is thrown if this timeout is exceeded.
          Set to -1 to wait indefinitely. -->

    <!-- username and password: MySQL username and password for database connections -->

    <!-- driverClassName: Class name for the old mm.mysql JDBC driver is org.gjt.mm.mysql.Driver
          - we recommend using Connector/J though.
          Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver. -->

    <!-- url: The JDBC connection url for connecting to your MySQL database. -->

    <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>

Bold 처리되어 있는 부분을 잘 참고하도록 하자.

Context 설정을 제대로 해주지 않으면,
"이 컨텍스트에 바인딩되지 않았습니다. jdbc 을 를 찾을 수 없습니다"라는 에러가 발생할 수 있다.

반응형