0

I am making a simple program using MyBatis. At this time, I am having difficulty applying DBCP to the configuration file(mybatis-config.xml) containg DB connection information.

<property name="initialSize" value="5" />
<property name="testOnReturn" value="true" />
<property name="maxActive" value="30" />
<property name="maxIdle" value="5" />
<property name="maxWait" value="-1" />
<property name="testOnBorrow" value="true" />
<property name="testWhileIdle" value="true" />
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="60" />
<property name="logAbandoned" value="true" />
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<property name="minEvictableIdleTimeMillis" value="60000" />
<property name="validationQuery" value="select 1 from dual" />
<property name="numTestsPerEvictionRun" value="20" />

When I did this and ran the program, I got the following error:

Error building SqlSession The error may exist in SQL Mapper Configuration Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.datasource.DataSourceException: Unknown Datasource property: maxIdle

If the property names is change as below, it runs without error:

<property name="poolMaximumActiveConnections" value="30" />
<property name="poolMaximumIdleConnections" value="5" />
<property name="poolMaximumCheckoutTime" value="-1" />

From what I've found, the above method that gives me an error has items I want to set, so I want to solve this error. Do you know anyone well? For reference, java version is 1.8 and mybatis-3.1.1.jar is applied. I tried applying commons-dbcp-1.4.jar just in case, but the error is the same before or after applying the library.

Please tell me your options.

borchvm
  • 3,533
  • 16
  • 44
  • 45
na_dev
  • 1
  • 1
  • `BasicDataSource Configuration Parameters` (https://commons.apache.org/proper/commons-dbcp/configuration.html ) `maxIdle 8 The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit. ` , `VERSION: 2.9.0`, `VERSION: 2.9.0`,`VERSION: 2.9.0` – life888888 Feb 24 '23 at 00:46
  • @na_dev DBCP 1.4 is very old and has known issues. Use DBCP 2.x or something else. You seem to be using the built-in "POOLED" data source. If you want to use 3rd party connection pool, you need to write an adapter. Please see the [doc](https://mybatis.org/mybatis-3/configuration.html#environments) for the details. – ave Feb 24 '23 at 07:23

0 Answers0