parent
fc01760722
commit
d09b59f3bd
18 changed files with 132 additions and 16 deletions
@ -0,0 +1,32 @@ |
||||
package org.panda.jdbc.sql; |
||||
|
||||
/** |
||||
* @Author: qi |
||||
* @Description: |
||||
* @Date: Create in 6:28 AM 2019/5/6 |
||||
*/ |
||||
public class SqlConstant { |
||||
|
||||
/** |
||||
* SQL 切割符 |
||||
*/ |
||||
public static final String SQL_SYMBOL = "_"; |
||||
/** |
||||
* 数据库类型常量:mysql |
||||
*/ |
||||
public static final String DB_TYPE_MYSQL = "mysql"; |
||||
/** |
||||
* 数据库类型常量:oracle |
||||
*/ |
||||
public static final String DB_TYPE_ORACLE = "oracle"; |
||||
|
||||
/** |
||||
* 常用SQL 关键字:FROM |
||||
*/ |
||||
public static final String FROM_SQL = "FROM "; |
||||
/** |
||||
* 常用SQL 关键字:order |
||||
*/ |
||||
public static final String ORDER_SQL="ORDER"; |
||||
|
||||
} |
@ -0,0 +1,14 @@ |
||||
package org.panda.jdbc.sql.factory; |
||||
|
||||
|
||||
import org.panda.jdbc.sql.AbstractDbBuiler; |
||||
|
||||
/** |
||||
* Sql 构造器工厂 |
||||
* 作用:解耦使用者与具体实现类关系 |
||||
* @author qi |
||||
*/ |
||||
public interface DbBuilerFactory { |
||||
|
||||
AbstractDbBuiler getSqlBuilder(String dbType); |
||||
} |
@ -0,0 +1,30 @@ |
||||
package org.panda.jdbc.sql.factory.impl; |
||||
|
||||
|
||||
import org.panda.jdbc.sql.AbstractDbBuiler; |
||||
import org.panda.jdbc.sql.MysqlBuilder; |
||||
import org.panda.jdbc.sql.OracleBuiler; |
||||
import org.panda.jdbc.sql.SqlConstant; |
||||
import org.panda.jdbc.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; |
||||
} |
||||
} |
Loading…
Reference in new issue