Language/Java

HikariCP (光) mybtis 설정

아르비스 2014. 11. 11. 14:54



boneCP 보다 배이상 빠르다는 HirariCP


그 설정 방법에 대해서 알아보자


Spring에 붙이는 경우 

pom.xml

 java 8

 <!-- HikariCP -->

  <dependency> 

      <groupId>com.zaxxer</groupId>

      <artifactId>HikariCP</artifactId> 

      <version>2.2.4</version> 

 </dependency>

java 6 or 7 

   <!-- HikariCP -->

 <dependency>

     <groupId>com.zaxxer</groupId>

     <artifactId>HikariCP-java6</artifactId>

     <version>2.2.4</version>

     <scope>compile</scope>

  </dependency>


code 차이는 모르겠지만, jar를 java version과 맞지 않을 경우,

아래와 같은 에러 발생함.


 nested exception is java.lang.UnsupportedClassVersionError: com/zaxxer/hikari/HikariConfig : Unsupported major.minor version 52.0


spring_context.xml 설정

       <!-- HikariCP -->

<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://70.121.244.203:3307/iofficeefss0001?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf8</prop>

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

                <prop key="password">ioffefss1234</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>


url : https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby