I am trying to configure HikariCp in MyBatis using XML configuration
I want to know how to set the hikariCongig object in object in the mapper configuration.
my config looks like this :
<environment id="development">
<transactionManager type="JDBC" />
<dataSource type="com.xyz.config.HikariCPDataSourceFactory" >
<property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/beta-prod-db" />
<property name="username" value="postgres" />
<property name="password" value="${password}" />
<property name="poolName" value="test"/>
<property name="maxPoolSize" value="20" />
<property name="registerMbeans" value="true"/>
<property name="minimumIdle" value="5"/>
</dataSource>
</environment>
HikariCPDataSourceFactory.java
public class HikariCPDataSourceFactory extends PooledDataSourceFactory {
public HikariCPDataSourceFactory() {
// HikariConfig hikariConfig = new HikariConfig();
this.dataSource = new HikariDataSource();
}
}
I don't find any online article that shows how to set the hikariConfig object in the hikariDataSource object through XML configuration.
using Spring I can create a bean for hikariConfig and pass it as a parameter in the hikariDataSource object, but here I am not using spring so need to find a way with XML.
Without the hikariConfig object, if I try to get the HikariPoolMXBean object from dataSource I get the exception
org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.
HikariCP 1.4.0 MBean InstanceNotFoundException
this article says it only works when I set the hikariConfig Object