类 SqlUtils
java.lang.Object
com.gdxsoft.easyweb.datasource.SqlUtils
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static booleancheckChnOrderByDatabase(String databaseType) 根据数据库类型判断是否采用中文排序表达式static booleancheckChnOrderByName(String fieldName) 根据字段名称判断是字段是否使用中文排序static booleancheckChnOrderByType(String dataType) 通过字段类型判断是否使用中文排序static booleancheckHaveSql(String sql) 去除SQL注释后/* 和 --,是否有可执行的sqlstatic booleancheckIsSelect(String sql) 检查是否为 select语句或标记为-- EWA_IS_SELECTstatic StringcheckSqlSafety(String sql) Check SQL for dangerous operations (DDL, destructive DML, file I/O, admin commands).static booleancheckStartWord(String sql, String word) 判断 特定字符出现在非注释的SQL的0位置,多行的SQL只进行第一次判断static StringchnOrderTemplate(String databaseType) 根据不同的数据库类型获取中文排序模板static booleanewaIsSelect(String sql) 强制执行为select 模式,解决with xxx as 语句后面的select
标记为:-- EWA_IS_SELECTstatic StringgetAutoField(String sql) 查找自增的sql的返回字段, 例如 -- auto MEMO_IDstatic String[]将表的列数据转换为拼接为字符串
例如 -- ewa_join join_name, key_field_namestatic String[]getKVParameters(String sql) 将表的列数据转换为JSONObject
例如: -- ewa_kv json_name, key_field_name, value_field_name
用于转换为RequestValue的json对象static StringgetMemoKeyWordLine(String sql, String checkName) 获取SQL语句中地备注(--)信息包含关键字的行static String[]getMemoParameters(String sql, String checkName) 获取SQL语句中地备注(--)包含关键字的参数
-- ewa_kv json_name, key_field_name, value_field_name
-- ewa_join join_name, key_field_namestatic String[]getSqlWithBlock(String sql) 获取 SQL 的with部分和sql部分,用于分页查询static String获取SQL语句中表名,例如 -- ewa_table_name 表名static boolean是否比较更新前和更新后字段的变化, 方式:
SQL 添加 -- COMPARATIVE_CHANGESstatic booleanisHsqlDb(DataConnection cnn) static booleanHSQLDB or H2static booleanisMySql(DataConnection cnn) static booleanMySQL or MariaDBstatic booleanisOracle(DataConnection cnn) static booleanOracle or DM达梦static booleanstatic booleanisPostgreSql(String databaseType) PostgreSQL or KingbaseES/ Kingbase (人大金仓)static booleanisSqlite(DataConnection cnn) static booleanSQLitestatic booleanstatic booleanisSqlServer(String databaseType) SQL Server or Sybasestatic String删除sql 的多行备注static StringreplaceChnOrder(String databaseType, String fieldName) 根据数据库类型来判断,替换select 中文排序字段表达式static StringreplaceChnOrder(String databaseType, String fieldName, String dataType) 根据数据库类型、字段名称、字段类型来判断并替换select 中文排序字段表达式static StringreplaceSqlAtWithChar64(String value, String databaseType) 将SQL语句中的@符号替换为各数据库的CHAR(64)表达式
-
字段详细资料
-
MYSQL_RESERVED
-
CHN_DBS
需要用中文排序的数据库类型 -
CHN_TEMPLATES
中文排序的模板列表,对应CHN_DBS
MySQL utf8 的中文排序 convert([FIELD] using gbk)
PostgreSQL utf8字段中文排序 convert_to([FIELD],'gb18030')
-
-
构造器详细资料
-
SqlUtils
public SqlUtils()
-
-
方法详细资料
-
replaceSqlAtWithChar64
-
getTableNameBySqlComment
-
getAutoField
-
getJoinValueParameters
-
getKVParameters
-
getMemoParameters
-
getMemoKeyWordLine
-
getSqlWithBlock
-
checkStartWord
-
checkIsSelect
-
isComparativeChanges
是否比较更新前和更新后字段的变化, 方式:
SQL 添加 -- COMPARATIVE_CHANGES- 参数:
sql-- 返回:
-
removeSqlMuitiComment
-
checkHaveSql
-
ewaIsSelect
强制执行为select 模式,解决with xxx as 语句后面的select
标记为:-- EWA_IS_SELECT- 参数:
sql-- 返回:
- true/false
-
isMySql
-
isMySql
-
isSqlServer
-
isSqlServer
-
isPostgreSql
PostgreSQL or KingbaseES/ Kingbase (人大金仓)- 参数:
databaseType-- 返回:
-
isPostgreSql
-
isOracle
-
isOracle
-
isHsqlDb
-
isHsqlDb
-
isSqlite
-
isSqlite
-
checkChnOrderByDatabase
根据数据库类型判断是否采用中文排序表达式- 参数:
databaseType- 数据库类- 返回:
- 是否使用
-
checkChnOrderByType
-
checkChnOrderByName
根据字段名称判断是字段是否使用中文排序- 参数:
fieldName- 字段名称- 返回:
-
chnOrderTemplate
-
replaceChnOrder
-
replaceChnOrder
-
checkSqlSafety
Check SQL for dangerous operations (DDL, destructive DML, file I/O, admin commands). MySQL DDL causes implicit commit, making transaction rollback ineffective — must be blocked before execution.- 参数:
sql- raw SQL (supports multiple statements separated by ;)- 返回:
- null if safe, or error message string if dangerous
-