diff --git a/rxlib-x/src/main/java/org/rx/jdbc/JdbcUtil.java b/rxlib-x/src/main/java/org/rx/jdbc/JdbcUtil.java index b40d912b..35e7a9bb 100644 --- a/rxlib-x/src/main/java/org/rx/jdbc/JdbcUtil.java +++ b/rxlib-x/src/main/java/org/rx/jdbc/JdbcUtil.java @@ -205,6 +205,16 @@ public static void print(ResultSet resultSet) { } } + @SneakyThrows + public static T executeScalar(ResultSet resultSet) { + try (ResultSet rs = resultSet) { + if (rs.next()) { + return (T) rs.getObject(1); + } + return null; + } + } + public static final BiFunc TO_CAMEL_COLUMN_MAPPING = p -> CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, p); public static List readAs(ResultSet resultSet, Type type) {