From ead3d83c86e3d41db4087ed6a484964b46b4c58d Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Tue, 5 Jul 2022 23:54:43 +0700 Subject: [PATCH] Updated jdbc data query manager and service --- README.md | 1 + .../java/com/cubetiqs/sql/DataFactory.java | 69 ---------------- .../java/com/cubetiqs/sql/IDataManager.java | 3 +- .../com/cubetiqs/sql/JdbcDataFactory.java | 79 +++++++++++++++++++ 4 files changed, 82 insertions(+), 70 deletions(-) delete mode 100644 src/main/java/com/cubetiqs/sql/DataFactory.java create mode 100644 src/main/java/com/cubetiqs/sql/JdbcDataFactory.java diff --git a/README.md b/README.md index 7814f18..6e87961 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ - DataSource - Core Context for DSM +- DataFactory + JDBC Core # Contributors diff --git a/src/main/java/com/cubetiqs/sql/DataFactory.java b/src/main/java/com/cubetiqs/sql/DataFactory.java deleted file mode 100644 index 63928c1..0000000 --- a/src/main/java/com/cubetiqs/sql/DataFactory.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.cubetiqs.sql; - -import com.cubetiqs.mapper.MapperProvider; -import com.cubetiqs.mapper.RowMapperProvider; - -import java.util.List; -import java.util.Map; - -public final class DataFactory { - public static IExecuteResult> queryForList(JdbcDataQuery manager, String sql) { - return manager.queryForList(sql); - } - - public static IExecuteResult> queryForList(JdbcDataQuery manager, String sql, Object... args) { - return manager.queryForList(sql, args); - } - - public static IExecuteResult> queryForList(JdbcDataQuery manager, String sql, RowMapperProvider mapper) { - return manager.queryForList(sql, mapper); - } - - public static IExecuteResult> queryForList(JdbcDataQuery manager, String sql, RowMapperProvider mapper, Object... args) { - return manager.queryForList(sql, mapper, args); - } - - public static IExecuteResult queryForObject(JdbcDataQuery manager, String sql) { - return manager.queryForObject(sql); - } - - public static IExecuteResult queryForObject(JdbcDataQuery manager, String sql, Object... args) { - return manager.queryForObject(sql, args); - } - - public static IExecuteResult query(JdbcDataQuery manager, MapperProvider, R> mapper, String sql, Class clazz) { - return manager.query(mapper, sql, clazz); - } - - public static IExecuteResult query(JdbcDataQuery manager, MapperProvider, R> mapper, String sql, Class clazz, Object... args) { - return manager.query(mapper, sql, clazz, args); - } - - public static IExecuteResult query(JdbcDataQuery manager, String sql, RowMapperProvider mapper) { - return manager.query(sql, mapper); - } - - public static IExecuteResult query(JdbcDataQuery manager, String sql, RowMapperProvider mapper, Object... args) { - return manager.query(sql, mapper, args); - } - - public static IExecuteResult> queryForList(JdbcDataQuery manager, ISqlMapParameter parameter) { - return manager.queryForList(parameter); - } - - public static IExecuteResult> queryForList(JdbcDataQuery manager, ISqlMapParameter parameter, RowMapperProvider mapper) { - return manager.queryForList(parameter, mapper); - } - - public static IExecuteResult queryForObject(JdbcDataQuery manager, ISqlMapParameter parameter) { - return manager.queryForObject(parameter); - } - - public static IExecuteResult query(JdbcDataQuery manager, MapperProvider, R> mapper, ISqlMapParameter parameter, Class clazz) { - return manager.query(mapper, parameter, clazz); - } - - public static IExecuteResult query(JdbcDataQuery manager, ISqlMapParameter parameter, RowMapperProvider mapper) { - return manager.query(parameter, mapper); - } -} diff --git a/src/main/java/com/cubetiqs/sql/IDataManager.java b/src/main/java/com/cubetiqs/sql/IDataManager.java index 248edac..0f27430 100644 --- a/src/main/java/com/cubetiqs/sql/IDataManager.java +++ b/src/main/java/com/cubetiqs/sql/IDataManager.java @@ -1,7 +1,8 @@ package com.cubetiqs.sql; import java.sql.Connection; +import java.sql.SQLException; public interface IDataManager { - Connection getConnection(); + Connection getConnection() throws SQLException; } diff --git a/src/main/java/com/cubetiqs/sql/JdbcDataFactory.java b/src/main/java/com/cubetiqs/sql/JdbcDataFactory.java new file mode 100644 index 0000000..ae2a734 --- /dev/null +++ b/src/main/java/com/cubetiqs/sql/JdbcDataFactory.java @@ -0,0 +1,79 @@ +package com.cubetiqs.sql; + +import com.cubetiqs.mapper.MapperProvider; +import com.cubetiqs.mapper.RowMapperProvider; + +import java.util.List; +import java.util.Map; + +public final class JdbcDataFactory { + private final JdbcDataQuery queryManager; + + public JdbcDataFactory(JdbcDataQuery queryManager) { + this.queryManager = queryManager; + } + + public static JdbcDataFactory create(JdbcDataQuery queryManager) { + return new JdbcDataFactory(queryManager); + } + + public IExecuteResult> queryForList(String sql) { + return queryManager.queryForList(sql); + } + + public IExecuteResult> queryForList(String sql, Object... args) { + return queryManager.queryForList(sql, args); + } + + public IExecuteResult> queryForList(String sql, RowMapperProvider mapper) { + return queryManager.queryForList(sql, mapper); + } + + public IExecuteResult> queryForList(String sql, RowMapperProvider mapper, Object... args) { + return queryManager.queryForList(sql, mapper, args); + } + + public IExecuteResult queryForObject(String sql) { + return queryManager.queryForObject(sql); + } + + public IExecuteResult queryForObject(String sql, Object... args) { + return queryManager.queryForObject(sql, args); + } + + public IExecuteResult query(MapperProvider, R> mapper, String sql, Class clazz) { + return queryManager.query(mapper, sql, clazz); + } + + public IExecuteResult query(MapperProvider, R> mapper, String sql, Class clazz, Object... args) { + return queryManager.query(mapper, sql, clazz, args); + } + + public IExecuteResult query(String sql, RowMapperProvider mapper) { + return queryManager.query(sql, mapper); + } + + public IExecuteResult query(String sql, RowMapperProvider mapper, Object... args) { + return queryManager.query(sql, mapper, args); + } + + public IExecuteResult> queryForList(ISqlMapParameter parameter) { + return queryManager.queryForList(parameter); + } + + public IExecuteResult> queryForList(ISqlMapParameter parameter, RowMapperProvider mapper) { + return queryManager.queryForList(parameter, mapper); + } + + public IExecuteResult queryForObject(ISqlMapParameter parameter) { + return queryManager.queryForObject(parameter); + } + + public IExecuteResult query(MapperProvider, R> mapper, ISqlMapParameter parameter, Class clazz) { + return queryManager.query(mapper, parameter, clazz); + } + + public IExecuteResult query(ISqlMapParameter parameter, RowMapperProvider mapper) { + return queryManager.query(parameter, mapper); + } +}