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; + } +}