How to connect MySQL / MariaDB + HikariCP with Liferay 7 / DXP

Procedure for connecting HikariCP (Liferay DXP standard) and MySQL to the Connection pool with the Tomcat bundle

Liferay 7 / DXP uses the connection pool library HikariCP as standard. The following is the setting method to apply the latest database connector and connection pool library to connect to MySQL.

For MySQL

JNDI name, connection pool library settings

Add the following to portal-ext.properties

portal-ext.properties


setup.database.jar.url[com.mysql.jdbc.Driver]=http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.45/mysql-connector-java-5.1.45.jar
setup.liferay.pool.provider.jar.name[hikaricp]=hikaricp.jar
setup.liferay.pool.provider.jar.url[hikaricp]=http://central.maven.org/maven2/com/zaxxer/HikariCP/2.7.4/HikariCP-2.7.4.jar
jdbc.default.jndi.name=jdbc/LiferayPool
jdbc.default.liferay.pool.provider=hikaricp

ROOT.xml configuration sample

Describe the following resources between the <Context> tags.

Enter the address of the DB you are using in the [server-url-is-here] part. Enter the database name created in MySQL in the part of [your-DB-name-is-here]. Set dataSource.user and dataSource.password to those of your environment.

According to Liferay's Development Checklist, the maximum number of connections is 75 with the following settings, but please change it according to your environment. It is also necessary to change the number of thread pools according to the number of database connections. Generally, the database pool size is about 30% to 40% of the thread pool size, so it is assumed that the thread pool at this time is set to about 250.

xml:tomcat-8.0.32/conf/Catalina/localhost/ROOT.xml


<Resource
    auth="Container"
    type="javax.sql.DataSource"
    name="jdbc/LiferayPool"
    factory="com.zaxxer.hikari.HikariJNDIFactory"
    dataSourceClassName="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
    driverClass="com.mysql.jdbc.Driver"
    idleMaxAgeInMinutes="15"
    idleConnectionTestPeriodInMinutes="10"
    partitionCount="3"
    acquireIncrement="5"
    maxConnectionsPerPartition="25"
    minConnectionsPerPartition="4"
    statementsCacheSize="50"
    dataSource.url="jdbc:mysql://[server-url-is-here]:3306/[your-DB-name-is-here]?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false&amp;useSSL=false"
    dataSource.user="root"
    dataSource.password="password"
    jdbcUrl="jdbc:mysql://[server-url-is-here]:3306/[your-DB-name-is-here]?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false&amp;useSSL=false"/>

For MariaDB

JNDI name, connection pool library settings

Add the following to portal-ext.properties

portal-ext.properties


setup.database.jar.name[org.mariadb.jdbc.Driver]=mariadb.jar
setup.database.jar.url[org.mariadb.jdbc.Driver]=https://downloads.mariadb.com/Connectors/java/connector-java-2.2.0/mariadb-java-client-2.2.0.jar
setup.liferay.pool.provider.jar.name[hikaricp]=hikaricp.jar
setup.liferay.pool.provider.jar.url[hikaricp]=http://central.maven.org/maven2/com/zaxxer/HikariCP/2.7.4/HikariCP-2.7.4.jar
jdbc.default.jndi.name=jdbc/LiferayPool
jdbc.default.liferay.pool.provider=hikaricp

If mariadb.jar is not expanded to $ {tomcat_home} / lib / ext, download it manually and rename it to mariadb.jar and place it.

ROOT.xml configuration sample

As in MySQL, describe the following resources between the <Context> tags.

Enter the address of the DB you are using in the [server-url-is-here] part. Enter the database name created in MySQL in the part of [your-DB-name-is-here]. Set dataSource.user and dataSource.password to those of your environment.

xml:tomcat-8.0.32/conf/Catalina/localhost/ROOT.xml


<Resource
    auth="Container"
    type="javax.sql.DataSource"
    name="jdbc/LiferayPool"
    factory="com.zaxxer.hikari.HikariJNDIFactory"
    dataSourceClassName="org.mariadb.jdbc.MySQLDataSource"
    driverClass="org.mariadb.jdbc.Driver"
    idleMaxAgeInMinutes="15"
    idleConnectionTestPeriodInMinutes="10"
    partitionCount="3"
    acquireIncrement="5"
    maxConnectionsPerPartition="25"
    minConnectionsPerPartition="4"
    statementsCacheSize="50"
    jdbcUrl="jdbc:mariadb://[server-url-is-here]:3306/[your-DB-name-is-here]?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false&amp;useSSL=false"
    dataSource.url="jdbc:mariadb://[server-url-is-here]:3306/[your-DB-name-is-here]?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false&amp;useSSL=false"
    dataSource.user="root"
    dataSource.password="mariadb"
    />

Launch Liferay

Start Liferay with tomcat-8.0.32 / bin / startup.sh for Mac / * nix and tomcat-8.0.32 / bin / startup.bat for Windows.

Recommended Posts

How to connect MySQL / MariaDB + HikariCP with Liferay 7 / DXP
Connect to MySQL 8 with Java
How to create a theme in Liferay 7 / DXP
[Java] Connect to MySQL
How to install MySQL
I started MySQL 5.7 with docker-compose and tried to connect
How to number (number) with html.erb
How to update with activerecord-import
Connect to DB with Java
Connect to oracle with eclipse!
[Android] Connect to MySQL (unfinished)
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
Connect to multiple MySQL instances with SSL enabled in JDBC
How to use mysql with M1 mac Docker preview version
How to create a service builder portlet in Liferay 7 / DXP
Check how to set the timeout when connecting with Spring + HikariCP + MySQL and executing SQL
How to scroll horizontally with ScrollView
How to get started with slim
How to enclose any character with "~"
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ MySQL edition ~
mysql2 fails to install with bundle install
How to use mssql-tools with alpine
How to connect Heroku and Sequel
How to install MariaDB 10.4 on CentOS 8
Connect to Rails server with iPhone
How to get along with Rails
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Sequelize ~
Update MySQL from 5.7 to 8.0 with Docker
How to start Camunda with Docker
How to call libraries such as JQuery and JQuery UI in Liferay 7 / DXP
[Swift] How to connect TabBar with Storyboard Reference and also use NavigationController
Connect to Amazon EC2 with SSH (Ubuntu)
How to crop an image with libGDX
How to adjustTextPosition with iOS Keyboard Extension
How to share files with Docker Toolbox
How to compile Java with VsCode & Ant
[Java] How to compare with equals method
[Android] How to deal with dark themes
How to use BootStrap with Play Framework
[Rails] How to use rails console with docker
How to switch thumbnail images with JavaScript
Deploy to heroku with Docker (Rails 6, MySQL)
[Note] How to get started with Rspec
How to use MySQL in Rails tutorial
How to do API-based control with cancancan
Connect from Java to MySQL using Eclipse
How to achieve file download with Feign
How to update related models with accepts_nested_attributes_for
How to set JAVA_HOME with Maven appassembler-maven-plugin
How to implement TextInputLayout with validation function
How to handle sign-in errors with devise
How to delete data with foreign key
How to test private scope with JUnit
How to monitor nginx with docker-compose with datadog
How to deal with Precompiling assets failed.
How to achieve file upload with Feign
How to run Blazor (C #) with Docker
How to build Rails 6 environment with Docker
[Rails6] How to connect the posting function generated by Scaffold with the user function generated by devise
[Java] I tried to connect using a connection pool with Servlet (tomcat) & MySQL & Java