The code looks like this:
<!-- Configure Data Source--> <bean id="dataSource"> <!-- Basic properties url, user, password --> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/ssmhello" /> <property name="username" value="root" /> <property name="password" value="2424246258" /> <property name="initialSize" value="1" /> <property name="minIdle" value="1" /> <property name="maxActive" value="20" /> <property name="maxWait" value="60000" /> <!-- Whether to recycle after the time limit --> <property name="removeAbandoned" value="true" /> <!-- How long does it take to exceed the time limit; --> <property name="removeAbandonedTimeout" value="180" /> <!-- How long does it take to perform a detection interval to detect idle connections that need to be closed, in milliseconds --> <property name="timeBetweenEvictionRunsMillis" value="60000" /> <!-- Configure the minimum time for a connection to survive in the pool, in milliseconds --> <property name="minEvictableIdleTimeMillis" value="300000" /> <!-- SQL used to detect whether the connection is valid, requires a query statement --> <property name="validationQuery" value="SELECT 1" /> <!-- Test when applying for a connection --> <property name="testWhileIdle" value="true" /> <!-- Execute validationQuery when applying for a connection to check whether the connection is valid. Configure true to reduce performance --> <property name="testOnBorrow" value="false" /> <!-- Perform validationQuery when returning the connection to check whether the connection is valid. Configuring true will reduce performance --> <property name="testOnReturn" value="false" /> </bean>
<bean id="dataSource">
class of this tag has already configured the connection pool
Here we use the most popular Alibaba Druid connection pool, which is actually a class that uses the connection pool.
The above is the editor’s introduction to how Mybatis configures the connection pool. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!