I have an error when I create a Hikari connection, in a past have using mysql-connector but finally I decided use hikaricp.
This is the error:
[04:17:49] [Server thread/INFO]: HikariPool-1 - Starting...
[04:17:49] [Server thread/INFO]: HikariPool-1 - Driver does not support get/set network timeout for connections. (com.mysql.jdbc.JDBC4Connection.getNetworkTimeout()I)
[04:17:49] [Server thread/INFO]: HikariPool-1 - Start completed.
My function:
private static final HikariConfig config;
private HikariDataSource dataSource;
static {
config = new HikariConfig();
}
public void open(){
config.setJdbcUrl("jdbc:mysql://localhost:3306/"+ database);
config.setUsername(user);
config.setPassword(password);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
dataSource = new HikariDataSource(config);
}
I have this pom.xml:
<dependencies>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.4.5</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.divecrafts</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
</dependency>
</dependencies>
My dedicated server is debian 9 using mariadb (latest version)
2
Answers
I fixed modifying my function:
And my pom.xml
In summary, since I use mariadb I have added mariadb connector.
It looks to me like a version mismatch issue. The
setNetworkTimeout()
was introduced inJDBC 4.1
and was not present inJDBC 4.0
. From your stacktrace , it can be seen that :this is what causing the issue. So , I suggest updating the mysql driver and any related dependencies to the latest version possible which should resolve your connection issue.