类 DataConnection
java.lang.Object
com.gdxsoft.easyweb.datasource.DataConnection
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidbatchUpdate(List<String> sqls, boolean transcation) 批处理导入数据static booleancheckIsProcdure(String sql) 检查是否为 存储过程,例如 CALL pr_batAdd(@a)static booleancheckIsSelect(String sql) 检查是否为 存储过程,例如 CALL pr_batAdd(@a)static booleancheckStartWord(String sql, String word) 判断 特定字符出现在非注释的SQL的0位置,多行的SQL只进行第一次判断voidClear the errorvoid清除所有返回的 resultSet,当长期执行查询的时,会造成内存占用过高 关闭连接会自动执行清除voidclose()关闭所有连接,包括ResultSet,Cst,PstcloseStatment(Statement stmt) booleanconnect()convertToList(String[] sqlArray) boolean执行多个更新 sql语句,语句用“;”分割,不能在拼接的Sql中有“;”出现executeProcdure(String callProcduceSql) 执行存储过程void执行存储过程, 不带参数executeProcdureReturnResults(String callProcduceSql) 执行存储过程booleanexecuteQuery(String sql) 执行查询executeQueryAndReturnTables(String sql, String configName, RequestValue rv) 执行SQL查询返回多条结果集booleanbooleanexecuteQueryPage(String sql, String pkFieldName, int currentPage, int pageSize) 执行分页查询booleanexecuteUpdate(String sql) 执行更新执行更新并返回数据的前后差异intexecuteUpdateBatch(String sqls) 批处理执行sql语句,sql语句用 ; 分割intexecuteUpdateBatch(List<String> sqls) 批量执行sql语句booleanint执行自增的插入执行查询并返回 自动增加值(返回为对象,需要自己判断是int还是long)static StringgetAutoField(String sql) 查找自增的sql的返回字段, 例如 -- auto MEMO_ID数据库名称获取ListFrame查询的日期表达式Return the error with SQLReturn the error without sql从执行完的sql中获取更多的结果集intgetRecordCount(String sql) 获取记录数com.gdxsoft.easyweb.utils.msnet.MList将sql混合语句,通过“;”符号,分解为sql列表int用户和系统的时差(分钟)getTimestamp(String s1) 获取sql的timestamp数据static boolean是否比较更新前和更新后字段的变化, 方式:
SQL 添加 -- COMPARATIVE_CHANGESbooleanisTrans()是否使用事物处理rebuildSql(String sql) 1.static String删除sql 的多行备注runMultiSqls(String[] sqlArray) 执行混合SQL语句(查询,更新(包含返回自增),存储过程)
1.runMultiSqls(List<String> listSqls) 执行混合SQL语句(查询,更新(包含返回自增),存储过程)
1.runMultiSqlsAndClose(String sqls, String configName, RequestValue rv) 执行混合SQL语句(查询,更新(包含返回自增),存储过程)runMultiSqlsAndClose(List<String> listSqls, String configName, RequestValue rv) 执行混合SQL语句(查询,更新(包含返回自增),存储过程)voidsetConfigName(String configName) voidsetConfigName(String configName, String dataBaseName) 设置数据库连接池句柄voidsetConnection(Connection cnn) voidsetCurrentConfig(ConnectionConfig currentConfig) voidsetDataBaseName(String dataBaseName) 数据库名称voidsetDataHelper(DataHelper dataHelper) voidsetDebugFrames(DebugFrames debugFrames) voidsetErrorMsg(String errorMessage) Manual set conn error messagevoidsetRequestValue(RequestValue requestValue) voidsetTimeDiffMinutes(int timeDiffMinutes) 用户和系统的时差(分钟)sqlFieldOrTableExp(String fieldOrTable) 处理字段或表名的字符串表达式,带上[(sqlserver)或`(mysql)sqlParameterStringExp(String parameter) SQL字符串参数值表达式,替换'号和\转译符号(mysql)boolean开始事务处理void关闭事务连接boolean提交事务void事务回滚static StringupdateAndClose(StringBuilder sb, String configName, RequestValue rv) static StringupdateAndClose(String sql, String configName, RequestValue rv) 执行更新并关闭连接static StringupdateBatchAndClose(StringBuilder sb, String configName, RequestValue rv) 批量执行更新并关闭连接static StringupdateBatchAndClose(String sqls, String configName, RequestValue rv) 批量执行更新并关闭连接static StringupdateBatchAndClose(List<String> sqls, String configName, RequestValue rv) 批量执行更新并关闭连接static StringupdateBatchAndCloseTransaction(List<String> sqls, String configName, RequestValue rv) 批量执行更新并关闭连接 (Transaction)
-
构造器详细资料
-
DataConnection
public DataConnection() -
DataConnection
-
DataConnection
-
-
方法详细资料
-
getTimeDiffMinutes
public int getTimeDiffMinutes()用户和系统的时差(分钟)- 返回:
-
setTimeDiffMinutes
public void setTimeDiffMinutes(int timeDiffMinutes) 用户和系统的时差(分钟)- 参数:
timeDiffMinutes- 分钟
-
updateAndClose
执行更新并关闭连接- 参数:
sql-configName-rv-- 返回:
- 返回是否错误
-
updateAndClose
-
updateBatchAndClose
批量执行更新并关闭连接- 参数:
sqls- 用;分割的sql字符串configName-rv-- 返回:
- 返回是否错误
-
updateBatchAndClose
批量执行更新并关闭连接- 参数:
sb- 用;分割的sql字符串configName-rv-- 返回:
-
updateBatchAndClose
批量执行更新并关闭连接- 参数:
sqls- sql列表configName-rv-- 返回:
- 返回是否错误
-
updateBatchAndCloseTransaction
public static String updateBatchAndCloseTransaction(List<String> sqls, String configName, RequestValue rv) 批量执行更新并关闭连接 (Transaction)- 参数:
sqls- sql列表configName-rv-- 返回:
- 返回是否错误
-
runMultiSqlsAndClose
public static List<DTTable> runMultiSqlsAndClose(String sqls, String configName, RequestValue rv) throws Exception 执行混合SQL语句(查询,更新(包含返回自增),存储过程)- 参数:
sqls-configName-rv-- 返回:
- 返回的所有表
- 抛出:
Exception
-
runMultiSqlsAndClose
public static List<DTTable> runMultiSqlsAndClose(List<String> listSqls, String configName, RequestValue rv) throws Exception 执行混合SQL语句(查询,更新(包含返回自增),存储过程)- 参数:
listSqls-configName-rv-- 返回:
- 返回的所有表
- 抛出:
Exception
-
executeQueryAndReturnTables
public static List<DTTable> executeQueryAndReturnTables(String sql, String configName, RequestValue rv) throws SQLException 执行SQL查询返回多条结果集- 参数:
sql-configName-rv-- 返回:
- 结果集
- 抛出:
SQLException
-
getAutoField
查找自增的sql的返回字段, 例如 -- auto MEMO_ID- 参数:
sql-- 返回:
-
checkIsProcdure
检查是否为 存储过程,例如 CALL pr_batAdd(@a)- 参数:
sql-- 返回:
-
checkIsSelect
检查是否为 存储过程,例如 CALL pr_batAdd(@a)- 参数:
sql-- 返回:
-
checkStartWord
判断 特定字符出现在非注释的SQL的0位置,多行的SQL只进行第一次判断- 参数:
sql-word- 关键单词,例如SELECT- 返回:
-
removeSqlMuitiComment
删除sql 的多行备注- 参数:
sql-- 返回:
-
isComparativeChanges
是否比较更新前和更新后字段的变化, 方式:
SQL 添加 -- COMPARATIVE_CHANGES- 参数:
sql-- 返回:
-
getSqls
将sql混合语句,通过“;”符号,分解为sql列表- 参数:
sqls-- 返回:
- sql列表
-
getDataBaseName
数据库名称- 返回:
-
setDataBaseName
数据库名称- 参数:
dataBaseName-
-
transBegin
public boolean transBegin()开始事务处理- 返回:
-
transCommit
public boolean transCommit()提交事务- 抛出:
SQLException
-
transRollback
public void transRollback()事务回滚- 抛出:
SQLException
-
transClose
public void transClose()关闭事务连接 -
getCurrentConfig
-
setConfigName
-
setConfigName
设置数据库连接池句柄- 参数:
configName-dataBaseName-
-
connect
public boolean connect() -
executeQueryNoParameter
-
getMoreResults
从执行完的sql中获取更多的结果集- 返回:
- 抛出:
SQLException
-
executeQuery
执行查询- 参数:
sql-requestValue-- 返回:
-
executeQueryPage
执行分页查询- 参数:
sql-pkFieldName- 主键名称currentPage- 当前页码pageSize- 每页记录数- 返回:
-
closeStatment
-
batchUpdate
批处理导入数据- 参数:
sqls-transcation-
-
executeMultipleUpdate
执行多个更新 sql语句,语句用“;”分割,不能在拼接的Sql中有“;”出现- 参数:
sql-- 返回:
-
executeUpdateBatch
批量执行sql语句- 参数:
sqls-- 返回:
-
executeUpdateBatch
批处理执行sql语句,sql语句用 ; 分割- 参数:
sqls- sql语句用 ; 分割- 返回:
- -1 有错误
-
convertToList
-
runMultiSqls
执行混合SQL语句(查询,更新(包含返回自增),存储过程)
1. 如果是select返回数据的话,回将第一行数据放到 rv中
2. 自动创建变量 --auto xxx 会放到rv中
3. 存储过程返回的结果,带 _OUT参数,例如 ID_OUT 会放到rv中- 参数:
sqlArray-- 返回:
- select 返回 DTTable集合
- 抛出:
Exception
-
runMultiSqls
执行混合SQL语句(查询,更新(包含返回自增),存储过程)
1. 如果是select返回数据的话,回将第一行数据放到 rv中
2. 自动创建变量 --auto xxx 会放到rv中
3. 存储过程返回的结果,带 _OUT参数,例如 ID_OUT 会放到rv中- 参数:
listSqls-- 返回:
- 抛出:
Exception
-
executeUpdateReturnAutoIncrementObject
执行查询并返回 自动增加值(返回为对象,需要自己判断是int还是long)- 参数:
sql-- 返回:
-
executeUpdateReturnAutoIncrement
执行自增的插入- 参数:
sql-- 返回:
-
executeUpdate
执行更新- 参数:
sql-
-
executeUpdateAndReturnChanges
执行更新并返回数据的前后差异- 参数:
sql-- 返回:
-
executeUpdateNoParameter
-
getRecordCount
获取记录数- 参数:
sql-- 返回:
-
rebuildSql
1. 合成SQL语句,如果参数名为XX_SPLIT,为分割参数,
例如 select * from users where id in(1,2,3)
2. SQL语句预替换,即在SQL语句执行前,替换SQL语句本身的参数
例如 SELECT * FROM ~TB, 如参数TB是 USERS 则替换成 SELECT * FROM USERS- 参数:
sql-requestValue-- 返回:
- 抛出:
Exception
-
clearResultSets
public void clearResultSets()清除所有返回的 resultSet,当长期执行查询的时,会造成内存占用过高 关闭连接会自动执行清除 -
close
public void close()关闭所有连接,包括ResultSet,Cst,Pst -
getErrorMsg
Return the error with SQL- 返回:
-
setErrorMsg
Manual set conn error message- 参数:
errorMessage-
-
clearErrorMsg
public void clearErrorMsg()Clear the error -
executeProcdure
执行存储过程- 参数:
callProcduceSql- 存储过程调用方法: call pr_some(@name, @id_int_output)
结尾为_output,表示是输出参数
_int_output,表示输出参数为整形
_smallint_output,表示输出参数为小整形
_tinyint_output,表示输出参数为短整形
_number_output,_money_output,_numeric_output,_decimal_output表示输出参数为bcd数值
_long_output/_bigint_output,表示输出参数为长整形
_text_output/_clob_output,表示输出参数为长文本
_image_output/_blob_output,表示输出参数为长二进制
_binary_output/_byte_output,表示输出参数为二进制(varbinary)
_date_output/_datetime_output/_timestamp_output,表示输出参数为日期时间
_time_output,表示输出参数为时间
默认,为varchar字符串- 返回:
- 输出参数Map,key转换为大写
-
executeProcdureReturnResults
执行存储过程- 参数:
callProcduceSql- 存储过程调用方法: call pr_some(@name, @id_int_output)
结尾为_output,表示是输出参数
_int_output,表示输出参数为整形
_smallint_output,表示输出参数为小整形
_tinyint_output,表示输出参数为短整形
_number_output,_money_output,_numeric_output,_decimal_output表示输出参数为bcd数值
_long_output/_bigint_output,表示输出参数为长整形
_text_output/_clob_output,表示输出参数为长文本
_image_output/_blob_output,表示输出参数为长二进制
_binary_output/_byte_output,表示输出参数为二进制(varbinary)
_date_output/_datetime_output/_timestamp_output,表示输出参数为日期时间
_time_output,表示输出参数为时间
默认,为varchar字符串- 返回:
- 输出参数Map,key转换为大写,
RS_SIZE 表示返回的结果集数量
返回的结果集转换为DTTable,名字以RS开头,RS0,RS1,RS2 ...
-
executeProcdureNoParameter
执行存储过程, 不带参数- 参数:
sql-requestValue-
-
sqlParameterStringExp
SQL字符串参数值表达式,替换'号和\转译符号(mysql)- 参数:
parameter- 字符串参数值- 返回:
-
sqlFieldOrTableExp
处理字段或表名的字符串表达式,带上[(sqlserver)或`(mysql)- 参数:
fieldOrTable- 字段或表名- 返回:
- 带上[(sqlserver)或`(mysql)的字段或表名
-
getConnectionString
-
getDatabaseType
-
getDateTimePara
获取ListFrame查询的日期表达式- 参数:
s1-- 返回:
-
getDateTimePara
-
getTimestamp
获取sql的timestamp数据- 参数:
s1-- 返回:
-
getSchemaName
-
getConnection
-
setConnection
-
setCurrentConfig
- 参数:
currentConfig- the _CurrentConfig to set
-
getDebugFrames
- 返回:
- the _DebugFrames
-
setDebugFrames
- 参数:
debugFrames- the _DebugFrames to set
-
getRequestValue
- 返回:
- the _RequestValue
-
setRequestValue
- 参数:
requestValue- the _RequestValue to set
-
getResultSetList
public com.gdxsoft.easyweb.utils.msnet.MList getResultSetList()- 返回:
- the _ResultSetList
-
getLastResult
-
isTrans
public boolean isTrans()是否使用事物处理- 返回:
- the _IsTrans
-
getErrorMsgOnly
Return the error without sql- 返回:
-
getDataHelper
- 返回:
- the DataHelper
-
setDataHelper
- 参数:
dataHelper- the DataHelper to set
-