From 5e3972670d6e87159ceffe163cf81d4777b99394 Mon Sep 17 00:00:00 2001 From: qi Date: Fri, 16 Aug 2019 19:36:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9ESql=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E5=99=A8=E5=B7=A5=E5=8E=82=EF=BC=8C=E8=A7=A3=E8=80=A6Sql?= =?UTF-8?q?=E6=9E=84=E9=80=A0=E5=99=A8=E5=AE=9E=E7=8E=B0=E4=B8=8E=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=80=85=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/sql/factory/DbBuilerFactory.java | 12 ++++++++ .../factory/impl/DefaultDbBuilerFactory.java | 29 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/main/java/com/lq/code/util/sql/factory/DbBuilerFactory.java create mode 100644 src/main/java/com/lq/code/util/sql/factory/impl/DefaultDbBuilerFactory.java diff --git a/src/main/java/com/lq/code/util/sql/factory/DbBuilerFactory.java b/src/main/java/com/lq/code/util/sql/factory/DbBuilerFactory.java new file mode 100644 index 0000000..a0e9eb9 --- /dev/null +++ b/src/main/java/com/lq/code/util/sql/factory/DbBuilerFactory.java @@ -0,0 +1,12 @@ +package com.lq.code.util.sql.factory; + +import com.lq.code.util.sql.AbstractDbBuiler; + +/** + * Sql 工厂 + * @author qi + */ +public interface DbBuilerFactory { + + AbstractDbBuiler getSqlBuilder(String dbType); +} diff --git a/src/main/java/com/lq/code/util/sql/factory/impl/DefaultDbBuilerFactory.java b/src/main/java/com/lq/code/util/sql/factory/impl/DefaultDbBuilerFactory.java new file mode 100644 index 0000000..5f62bb0 --- /dev/null +++ b/src/main/java/com/lq/code/util/sql/factory/impl/DefaultDbBuilerFactory.java @@ -0,0 +1,29 @@ +package com.lq.code.util.sql.factory.impl; + +import com.lq.code.util.sql.AbstractDbBuiler; +import com.lq.code.util.sql.MysqlBuilder; +import com.lq.code.util.sql.OracleBuiler; +import com.lq.code.util.sql.SqlConstant; +import com.lq.code.util.sql.factory.DbBuilerFactory; + +/** + * @author qi + * dbBuilfer 生产工厂模式默认实现 + */ +public class DefaultDbBuilerFactory implements DbBuilerFactory { + + @Override + public AbstractDbBuiler getSqlBuilder(String dbType) { + AbstractDbBuiler abstractDbBuiler = null; + switch (dbType){ + case SqlConstant + .DB_TYPE_MYSQL: + abstractDbBuiler = new MysqlBuilder(); + break; + case SqlConstant.DB_TYPE_ORACLE: + abstractDbBuiler = new OracleBuiler(); + break; + } + return abstractDbBuiler; + } +}