public class DBUtils
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
COLOMN_TYPE_PREFIX |
限定符和类型 | 方法和说明 |
---|---|
static void |
applyColumnTypeValue(Dialect dialect,
java.sql.Connection conn,
Table table,
java.lang.String columnName,
java.lang.Object columnDefValue,
java.sql.PreparedStatement pstatement,
int columnIndex,
int columnType,
java.lang.Object columnValue)
设置列类型
|
static java.lang.String |
changeCharset(java.lang.String returnObj,
java.lang.String oriCharsetName,
java.lang.String newCharsetName)
改变数据的字符集
|
static Connection |
checkDBConnection(java.lang.String name)
根据连接名取DatabaseConnection,取不到则返回null
|
static ColumnInformation[] |
checkInColumnInformation(java.sql.Connection connection,
Dialect dialect,
java.lang.String query)
获取列名信息
返回的Object[]里面有三样东西
{ColumnNameArray:String[]; ColumnTypeArray:int[]; ColumnTypeNameArray:String[]}
注意:这个方法结束时并不把connection关掉
|
static java.lang.String[] |
checkInColumnNames(java.sql.Connection connection,
Dialect dialect,
java.lang.String query)
获取列名数组
|
static JSONObject |
checkInColumnTypeMap(java.sql.Connection connection,
Dialect dialect,
java.lang.String query)
获取列名信息json配置
|
static void |
close(java.sql.Connection conn)
关闭数据连接
|
static void |
close(java.sql.ResultSet rs)
关闭结果集
|
static void |
close(java.sql.Statement stmt)
关闭连接
|
static void |
closeConnection(java.sql.Connection conn)
关闭数据连接
|
static void |
closeResultSet(java.sql.ResultSet rs)
关闭结果集
|
static void |
closeStatement(java.sql.Statement stmt)
关闭连接
|
static void |
commitConnections(java.util.Map<java.lang.String,java.sql.Connection> connectionMap)
统一提交回滚处理
|
static int |
getColumnFRType(int type)
Get the column type that defined in finereport
|
static Connection |
getEmbeddedDB(java.lang.String dbName,
int CACHE_LOG_SIZE)
同方法 getEmbeddedDB(String dbName, Map propertyMap, int CACHE_LOG_SIZE, DBCPConnectionPoolAttr attr);
这个方法会自己配置一个合适的propertyMap和 DBCPConnectionPoolAttr
|
static Connection |
getEmbeddedDB(java.lang.String dbName,
java.util.Map propertyMap,
int CACHE_LOG_SIZE,
DBCPConnectionPoolAttr attr)
carl:
当前内置数据库使用HSQL
|
static boolean |
isExsitedTable(Connection databaseConnect,
java.lang.String tableName)
判断一个表格在数据库当中是否存在.
|
static boolean |
isNULL(java.lang.Object columnValue,
Dialect dialect)
是否为空
|
static boolean |
isProcedure(java.lang.String query)
p:这个方法用来判断这个SQL语句是否是存储过程,智能判断,根据{call.
33503 增加 {?
|
static void |
refreshDatabase()
刷新数据连接
|
static void |
rollback(java.sql.Connection conn)
数据回滚
|
public static final java.lang.String COLOMN_TYPE_PREFIX
public static void applyColumnTypeValue(Dialect dialect, java.sql.Connection conn, Table table, java.lang.String columnName, java.lang.Object columnDefValue, java.sql.PreparedStatement pstatement, int columnIndex, int columnType, java.lang.Object columnValue) throws java.sql.SQLException
dialect
- 数据库方言conn
- 数据连接table
- 数据表columnName
- 列名columnDefValue
- 列的配置值pstatement
- 连接信息columnIndex
- 列序列columnType
- 列类型columnValue
- 列值java.sql.SQLException
public static boolean isNULL(java.lang.Object columnValue, Dialect dialect)
columnValue
- 数据public static int getColumnFRType(int type)
type
- the sql type which defined in java.sql.TypesDBConstants.FR_STRING
,
DBConstants.FR_NUMBER
,
DBConstants.FR_NULL
,
DBConstants.FR_STREAM
,
DBConstants.FR_BOOLEAN
public static void closeConnection(java.sql.Connection conn)
conn
- 数据连接public static void close(java.sql.Statement stmt)
stmt
- 连接public static void close(java.sql.ResultSet rs)
rs
- 结果集public static void close(java.sql.Connection conn)
conn
- 数据连接public static void closeStatement(java.sql.Statement stmt)
stmt
- 连接public static void closeResultSet(java.sql.ResultSet rs)
rs
- 结果集public static void rollback(java.sql.Connection conn)
conn
- 数据连接public static java.lang.String[] checkInColumnNames(java.sql.Connection connection, Dialect dialect, java.lang.String query)
connection
- 数据连接query
- SQL语句public static JSONObject checkInColumnTypeMap(java.sql.Connection connection, Dialect dialect, java.lang.String query)
connection
- 数据连接query
- SQL语句public static Connection checkDBConnection(java.lang.String name)
name
- 数据连接名public static ColumnInformation[] checkInColumnInformation(java.sql.Connection connection, Dialect dialect, java.lang.String query) throws java.sql.SQLException
connection
- 当前连接query
- sql语句java.sql.SQLException
public static java.lang.String changeCharset(java.lang.String returnObj, java.lang.String oriCharsetName, java.lang.String newCharsetName)
returnObj
- 数据库数据oriCharsetName
- 源字符集newCharsetName
- 新的字符集public static boolean isProcedure(java.lang.String query)
query
- SQL语句public static boolean isExsitedTable(Connection databaseConnect, java.lang.String tableName)
databaseConnect
- 数据连接tableName
- 表名public static void refreshDatabase()
public static Connection getEmbeddedDB(java.lang.String dbName, int CACHE_LOG_SIZE)
dbName
- 数据库名称CACHE_LOG_SIZE
- 设置hsql public static Connection getEmbeddedDB(java.lang.String dbName, java.util.Map propertyMap, int CACHE_LOG_SIZE, DBCPConnectionPoolAttr attr)
dbName
- 数据库名称propertyMap
- HSQL数据库的配置参数attr
- 连接池属性CACHE_LOG_SIZE
- 设置hsql public static void commitConnections(java.util.Map<java.lang.String,java.sql.Connection> connectionMap) throws java.lang.Exception
connectionMap
- 连接的集合java.lang.Exception
- 写入异常