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