I am trying to configure HikariCp in mybatis using xml configuration
I want to know hoe 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 dont find any online article hat shows how to set the hikariConfig object in hikarIDataSource object through xml configuration.
using Spring i can crearte a bean for hikariConfig and pass it as a parameter in hikariDataSource object , but here i am not using spring so need to find a way with xml.
Without hikariConfig object if i try to get the HikariPoolMXBean object from datSource 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