I am using HikariCP and jdbc template to query from one database.The method i use is like below:
My Hikari CP config file(hikari.properties
):
driverClassName=org.postgresql.Driver
jdbcUrl=jdbc:postgresql://10.1.19.99:5432/mvc_data_base
maximumPoolSize=60
dataSource.cachePrepStmts=true
dataSource.prepStmtCacheSize=250
dataSource.prepStmtCacheSqlLimit=2048
I do the configuration by this
@Configuration
public class AppConfig {
@Bean(destroyMethod = "close")
public DataSource dataSource() throws SQLException {
HikariConfig config = new HikariConfig("D:/hikari.properties");
HikariDataSource dataSource = new HikariDataSource(config);
return dataSource;
}
}
I want to query I do by the JDBC template
public class UserDetail {
@Autowired
private JdbcTemplate jtmUserDetail;
List<Map<String, Object>> row1=
jtmUserDetail.queryForList("select * from pubic.user");
}
Now I want something like
public class UserDetail {
@Autowired
private JdbcTemplate jtmUserDetail;
@Autowired
private JdbcTemplate jtmUserDetail2;
List<Map<String, Object>> row1=
jtmUserDetail.queryForList("select * from pubic.user");
List<Map<String, Object>> row2=
jtmUserDetail2.queryForList("select * from pubic.user");
}
where jtmUserDetail
is querying from one database(mvc_data_base
) and jtmUserDetail2
from another(test_data_base
).
I am not sure how to specify which database to query here.