fix query
This commit is contained in:
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'ru.di9'
|
||||
version '1.9.1'
|
||||
version '1.9.2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.di9.jdbc;
|
||||
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.*;
|
||||
@@ -50,13 +51,14 @@ public class JdbcTemplateImpl implements JdbcTemplate {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T query(@Language("GenericSQL") String sql, PreparedStatementProcessor psp,
|
||||
ResultSetExtractor<T> rse) throws DataAccessException {
|
||||
try (Connection connection = dataSource.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
psp.process(preparedStatement);
|
||||
try (ResultSet resultSet = preparedStatement.executeQuery()) {
|
||||
return resultSet.next() ? rse.extractData(resultSet) : null;
|
||||
return rse.extractData(resultSet);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw throwDataAccessException(sql, e);
|
||||
|
||||
Reference in New Issue
Block a user