У меня есть класс DAO, который получает имена таблиц, которые соответствуют определенному шаблону.
@Repository
@Transactional
public class TableMetadataDAO {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private DataSource ds;
public List<ColumnMetadata> load() {
List<ColumnMetadata> list = jdbcTemplate.execute(new ConnectionCallback<List<ColumnMetadata>>() {
public List<ColumnMetadata> doInConnection(Connection con) throws SQLException {
List<ColumnMetadata> list = new ArrayList<>();
DatabaseMetaData metaData = con.getMetaData();
ResultSet rs = metaData.getColumns("", "", "tmp_%", "");
while (rs.next()) {
ColumnMetadata cmd = new ColumnMetadata();
cmd.setTableName(rs.getString("TABLE_NAME"));
list.add(cmd);
}
rs.close();
return list;
}
});
}
}
Я вызываю метод загрузки из теста с пружинной загрузкой:
@RunWith(SpringRunner.class)
@SpringBootTest
@TestPropertySource(locations="classpath:application-it.properties")
public class TableMetadataControllerTest {
@Autowired
private TableMetadataDAO tmd;
@SuppressWarnings("unchecked")
@Test
public void tmpTables() throws Exception {
List<ColumnMetadata> list = tmd.load();
}
}
Теперь я ставлю точку останова на List<ColumnMetadata> list = tmd.load();
и делаю шаг. Результат, который я получаю, правильный, оправдывает мои ожидания. Однако, когда я делаю шаг за шагом и обходя метод DAO, я получаю исключение на org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
при вызове метода rs.getString("TABLE_NAME")
.
Я действительно запутался и понятия не имею, что делать дальше, чтобы найти причину такого странного поведения. Не могли бы вы дать несколько советов, какие шаги можно предпринять, чтобы найти основную причину.
РЕДАКТИРОВАНИЕ:
Журнал конфигурации Hikari
2018-11-05 14:38:46.842 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : HikariPool-1 - configuration:
2018-11-05 14:38:46.917 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : allowPoolSuspension.............false
2018-11-05 14:38:46.923 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : autoCommit......................true
2018-11-05 14:38:46.928 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : catalog.........................none
2018-11-05 14:38:46.932 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : connectionInitSql...............none
2018-11-05 14:38:46.937 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : connectionTestQuery.............none
2018-11-05 14:38:46.942 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : connectionTimeout...............30000
2018-11-05 14:38:46.946 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : dataSource......................none
2018-11-05 14:38:46.951 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : dataSourceClassName.............none
2018-11-05 14:38:46.955 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : dataSourceJNDI..................none
2018-11-05 14:38:46.967 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : dataSourceProperties............{password=<masked>}
2018-11-05 14:38:46.973 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : driverClassName................."org.postgresql.Driver"
2018-11-05 14:38:46.978 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : healthCheckProperties...........{}
2018-11-05 14:38:46.983 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : healthCheckRegistry.............none
2018-11-05 14:38:46.987 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : idleTimeout.....................600000
2018-11-05 14:38:46.995 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : initializationFailFast..........true
2018-11-05 14:38:47.002 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : initializationFailTimeout.......1
2018-11-05 14:38:47.010 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : isolateInternalQueries..........false
2018-11-05 14:38:47.017 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : jdbc4ConnectionTest.............false
2018-11-05 14:38:47.022 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : jdbcUrl.........................jdbc:postgresql://0.0.0.0:5432/docker
2018-11-05 14:38:47.027 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : leakDetectionThreshold..........0
2018-11-05 14:38:47.032 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : maxLifetime.....................1800000
2018-11-05 14:38:47.036 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : maximumPoolSize.................10
2018-11-05 14:38:47.041 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : metricRegistry..................none
2018-11-05 14:38:47.046 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : metricsTrackerFactory...........com.zaxxer.hikari.metrics.micrometer.MicrometerMetricsTrackerFactory@1dd74143
2018-11-05 14:38:47.050 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : minimumIdle.....................10
2018-11-05 14:38:47.054 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : password........................<masked>
2018-11-05 14:38:47.059 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : poolName........................"HikariPool-1"
2018-11-05 14:38:47.065 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : readOnly........................false
2018-11-05 14:38:47.071 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : registerMbeans..................false
2018-11-05 14:38:47.076 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : scheduledExecutor...............none
2018-11-05 14:38:47.081 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : scheduledExecutorService........internal
2018-11-05 14:38:47.085 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : schema..........................none
2018-11-05 14:38:47.089 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : threadFactory...................internal
2018-11-05 14:38:47.093 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : transactionIsolation............default
2018-11-05 14:38:47.098 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : username........................"docker"
2018-11-05 14:38:47.102 DEBUG 32256 --- [ main] com.zaxxer.hikari.HikariConfig : validationTimeout...............5000
2018-11-05 14:38:47.105 INFO 32256 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...