Language/Java

DB Connection 설정 비교 (Spring, Mybatis)

아르비스 2014. 11. 11. 15:45

1. Tomcat JDBC

context.xml


<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">

<property name="driverClassName" value="com.mysql.jdbc.Driver"/>

<property name="url" value="jdbc:mysql://**.**.**.**:3306/iofficeefss0001"/>

<property name="username" value="ioffefss01"/>

<property name="password" value="****"/>

<property name="initialSize" value="1"/>

<property name="maxActive" value="2"/>

<property name="maxIdle" value="2"/>

<property name="minIdle" value="2"/>

<property name="maxWait" value="30000"/>

<property name="validationQuery" value="SELECT 1"/>

<property name="testWhileIdle" value="true"/>

<property name="timeBetweenEvictionRunsMillis" value="60000"/>

</bean>


2. BoneCP

context.xml


<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">

  <property name="driverClass" value="com.mysql.jdbc.Driver" />

  <property name="jdbcUrl" value="jdbc:mysql://**.**.**.**:3306/iofficeefss0001?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf8" />

  <property name="username" value="ioffefss01"/>

  <property name="password" value="****"/>

  <property name="idleConnectionTestPeriod" value="60"/>

  <property name="idleMaxAge" value="240"/>

  <property name="maxConnectionsPerPartition" value="30"/>

  <property name="minConnectionsPerPartition" value="10"/>

  <property name="partitionCount" value="3"/>

  <property name="acquireIncrement" value="5"/>

  <property name="statementsCacheSize" value="100"/>

  <property name="releaseHelperThreads" value="3"/>

</bean>


3. HiKariCP

context.xml

<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">

    <property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"/>

        <property name="dataSourceProperties">

            <props>

                <prop key="url">jdbc:mysql://**.**.**.**:3306/iofficeefss0001</prop>

                <prop key="user">ioffefss01</prop>

                <prop key="password">****</prop>

                <prop key="cachePrepStmts">true</prop>

                <prop key="prepStmtCacheSize">250</prop>

                <prop key="prepStmtCacheSqlLimit">2048</prop>

                <prop key="useServerPrepStmts">true</prop>

            </props>

        </property>

    </bean>


    <bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource"

          destroy-method="shutdown">

        <constructor-arg ref="hikariConfig"/>

    </bean>