Answer the question
In order to leave comments, you need to log in
How to fix error with HikariCP (MySQL) and jks java?
Tell me what the error can be, my config:
public synchronized static void init() {
if (dataSource != null) {
return;
}
try {
DatabaseConfig.DATABASE_DRIVER.newInstance();
}
catch (Exception e) {
log.error("[MySQLDatabaseFactory]: Error obtaining DB driver", e);
throw new Error("[MySQLDatabaseFactory]: DB Driver doesnt exist!");
}
System.setProperty("javax.net.ssl.trustStore", DatabaseConfig.DATABASE_JKS_PATCH.toString());
System.setProperty("javax.net.ssl.trustStorePassword", DatabaseConfig.DATABASE_JKS_PASSWORD.toString());
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(DatabaseConfig.DATABASE_CONNECTIONS_MAX);
config.setConnectionTimeout(DatabaseConfig.DATABASE_TIMEOUT);
config.setDataSourceClassName(DatabaseConfig.DATABASE_DRIVER.getName());
config.addDataSourceProperty("url", DatabaseConfig.DATABASE_URL);
config.addDataSourceProperty("user", DatabaseConfig.DATABASE_USER);
config.addDataSourceProperty("password", DatabaseConfig.DATABASE_PASSWORD);
dataSource = new HikariDataSource(config);
try {
Connection c = getConnection();
DatabaseMetaData dmd = c.getMetaData();
databaseName = dmd.getDatabaseProductName();
databaseMajorVersion = dmd.getDatabaseMajorVersion();
databaseMinorVersion = dmd.getDatabaseMinorVersion();
c.close();
}
catch (Exception e) {
log.error("[MySQLDatabaseFactory]: Error with connection string: " + DatabaseConfig.DATABASE_URL, e);
throw new Error("[MySQLDatabaseFactory]: DatabaseFactory not initialized!");
}
log.info("Successfully connected to database");
}
database.driver = com.mysql.cj.jdbc.MysqlDataSource
database.url = jdbc:mysql://*****:3306/*****?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=true
database.user = root
database.password = root
database.connectionpool.connections.min = 2
database.connectionpool.connections.max = 5
database.jks.patch = "truststore.jks"
database.jks.password = "password"
15:27:56.726 INFO [main]: - HikariPool-1 - Starting...
Exception in thread "main" com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Cannot open file:"truststore.jks" ["truststore.jks" (Синтаксическая ошибка в имени файла, имени папки или метке тома)]
at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:597)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:576)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
at com.lightning.digital.core.database.MySQLDatabaseFactory.init(MySQLDatabaseFactory.java:70)
at com.lightning.digital.login.LoginServer.main(LoginServer.java:59)
Caused by: java.sql.SQLNonTransientConnectionException: Cannot open file:"truststore.jks" ["truststore.jks" (Синтаксическая ошибка в имени файла, имени папки или метке тома)]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:70)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:832)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:393)
at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:125)
at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:110)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:353)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:562)
... 4 more
Caused by: com.mysql.cj.exceptions.SSLParamsException: Cannot open file:"truststore.jks" ["truststore.jks" (Синтаксическая ошибка в имени файла, имени папки или метке тома)]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
at com.mysql.cj.protocol.ExportControlled.getSSLContext(ExportControlled.java:546)
at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:301)
at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:206)
at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99)
at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:347)
at com.mysql.cj.protocol.a.NativeAuthenticationProvider.negotiateSSLConnection(NativeAuthenticationProvider.java:796)
at com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:503)
at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:220)
at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1443)
at com.mysql.cj.NativeSession.connect(NativeSession.java:165)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:952)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:822)
... 14 more
Caused by: java.io.FileNotFoundException: "truststore.jks" (Синтаксическая ошибка в имени файла, имени папки или метке тома)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at java.net.URL.openStream(URL.java:1045)
at com.mysql.cj.protocol.ExportControlled.getSSLContext(ExportControlled.java:515)
... 25 more
Answer the question
In order to leave comments, you need to log in
The reason for the error is usually reported in the text of the error.
Caused by: com.mysql.cj.exceptions.SSLParamsException: Cannot open file:"truststore.jks" ["truststore.jks" (Syntax error in file name, folder name, or volume label)]
Need to check if file exists and exists whether to access it.
Put a breakpoint on
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
and see where exactly the system is trying to take this file.
I would put a breakpoint on ExportControlled.java:515 .
And I would look at what path an attempt is made to find the jks file, and whether there is a valid file along this path.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question