Answer the question
In order to leave comments, you need to log in
How to solve java.sql.SQLException: Read timed out problem?
Good afternoon.
There is a project on Spring with two databases.
The connection is defined by the following code
@Bean
@Primary
@ConfigurationProperties("spring.pg.datasource")
public DataSourceProperties firstDataSourceProperties() {
return new DataSourceProperties();
}
@Bean
@ConfigurationProperties("spring.ch.datasource")
public DataSourceProperties secondDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "PG")
@Primary
@ConfigurationProperties("spring.pg.datasource.configuration")
public DataSource firstDataSource() {
return firstDataSourceProperties()
.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}
@Bean(name = "CH")
@ConfigurationProperties("spring.ch.datasource.configuration")
public DataSource secondDataSource() {
return secondDataSourceProperties()
.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}
java.sql.SQLException: Read timed out
at com.github.housepower.jdbc.connect.PhysicalConnection.receiveResponse(PhysicalConnection.java:88) ~[clickhouse-native-jdbc-1.7-stable.jar:na]
at com.github.housepower.jdbc.connect.PhysicalConnection.receiveHello(PhysicalConnection.java:72) ~[clickhouse-native-jdbc-1.7-stable.jar:na]
at com.github.housepower.jdbc.ClickHouseConnection.serverInfo(ClickHouseConnection.java:180) ~[clickhouse-native-jdbc-1.7-stable.jar:na]
at com.github.housepower.jdbc.ClickHouseConnection.createPhysicalInfo(ClickHouseConnection.java:164) ~[clickhouse-native-jdbc-1.7-stable.jar:na]
Answer the question
In order to leave comments, you need to log in
Problem solved,
I should have added the following line
@Bean(name = "CH")
@ConfigurationProperties("spring.ch.datasource.configuration")
public DataSource secondDataSource() {
<b> HikariConfig hikari = new HikariConfig();
hikari.setConnectionTestQuery("show tables");</b>
return secondDataSourceProperties()
.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question