@GetMapping("/myGetsomething")
@Transactional
public meDataClass givebyID(@PathVariable("ID") long id) throws NullPointerException {
try {
return postgresService.giveById(id);//возвращает экземпляр класса @Entity
} catch (NullPointerException e) {
throw new DataNotFoundException();
}
}
L2DatabaseFactory: Failed to retrieve database connection!
2019-10-22T03:06:59.940805Z 4807 [Warning] IP address 'XXX.XX.XX.XX' could not be resolved: Temporary failure in name resolution
Aborted connection 6374 to db: 'NAMEBASE' user: 'NAME' host: '109.196.134.84' (Got timeout reading communication packets)
HashMap <int,String>usersDict = new HashMap<int, String>();
i = 0;
for(String singleUser: users){
usersDict.put(id.get(i),singleUser);
i++;
}
Это создаст HashMap с ключами id - User.
Соответсвие будет по номеру элемента массива. Id(0) элемент массива, User(0) Элемент массива.
String reportPlace = String.format("\"%sreports/Task.jasper",
Thread.currentThread().getContextClassLoader()
.getResource("").getPath());
InputStream std = new FileInputStream(reportPlace);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(std);
"status": 500,
"error": "Internal Server Error",
"message": " \"file:\\D:\\Java\\Spriп\\target\\Tot.jar!\\BOOT-INF\\classes!\\reports\\Task.jasper (Синтаксическая ошибка в имени файла, имени папки или метке тома)",
@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();
}
@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(BasicDataSource.class).build();
}
@Bean(name = "CH")
@ConfigurationProperties("spring.ch.datasource.configuration")
public DataSource secondDataSource() {
return secondDataSourceProperties().initializeDataSourceBuilder()
.type(BasicDataSource.class).build();
}
@Qualifier("CH")
private JdbcTemplate ch;
@Autowired
public ClickHouseDAO1(JdbcTemplate dataSource) {
this.ch = dataSource;
}
public List<DataRecord> query(String query) {
List<DataRecord> answer = ch.query(query, DataRecord.Mapper.INSTANCE);
return answer;
}
Но оно не рабоет должным образом.