public abstract class DatabaseAccess extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected static org.slf4j.Logger |
logger |
| 限定符和类型 | 方法和说明 |
|---|---|
static Object |
callFunction(Connection conn,
String procName,
int sqlType,
Object... paramObjs)
调用数据库函数
|
static boolean |
callProcedure(Connection conn,
String procName,
Object... paramObjs)
执行一个存储过程
|
static int |
doExecuteNamedSql(Connection conn,
String sSql,
Map<String,Object> values) |
static boolean |
doExecuteSql(Connection conn,
String sSql)
直接运行SQL,update delete insert
|
static int |
doExecuteSql(Connection conn,
String sSql,
Object[] values) |
static String |
fetchBlobAsBase64(Blob blob) |
static byte[] |
fetchBlobBytes(Blob blob) |
static String |
fetchClobString(Clob clob) |
static Object |
fetchLobField(Object fieldData,
boolean blobAsBase64String) |
static com.alibaba.fastjson.JSONObject |
fetchResultSetRowToJSONObject(ResultSet rs,
String[] fieldnames) |
static Object[] |
fetchResultSetRowToObjects(ResultSet rs) |
static com.alibaba.fastjson.JSONArray |
fetchResultSetToJSONArray(ResultSet rs,
String[] fieldnames) |
static List<Object[]> |
fetchResultSetToObjectsList(ResultSet rs) |
static Object |
fetchScalarObject(List<Object[]> rsDatas) |
static List<Object> |
fetchSingleColumn(List<Object[]> rsDatas) |
static List<Object> |
fetchSingleColumn(List<Object[]> rsDatas,
int columnIndex) |
static List<String> |
fetchSingleColumnAsString(List<Object[]> rsDatas) |
static List<String> |
fetchSingleColumnAsString(List<Object[]> rsDatas,
int columnIndex) |
static com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(Connection conn,
String sSql) |
static com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(Connection conn,
String sSql,
Object value) |
static com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(Connection conn,
String sSql,
Object[] values) |
static com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(Connection conn,
String sSql,
Object[] values,
int pageNo,
int pageSize) |
static com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(Connection conn,
String sSql,
Object[] values,
String[] fieldnames) |
static com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(Connection conn,
String sSql,
Object[] values,
String[] fieldnames,
int pageNo,
int pageSize) |
static com.alibaba.fastjson.JSONArray |
findObjectsAsJSON(Connection conn,
String sSql,
Object value,
String[] fieldnames) |
static List<Object[]> |
findObjectsByNamedSql(Connection conn,
String sSql,
Map<String,Object> values) |
static List<Object[]> |
findObjectsByNamedSql(Connection conn,
String sSql,
Map<String,Object> values,
int pageNo,
int pageSize)
执行分页一个带命名参数的查询
|
static com.alibaba.fastjson.JSONArray |
findObjectsByNamedSqlAsJSON(Connection conn,
String sSql,
Map<String,Object> values) |
static com.alibaba.fastjson.JSONArray |
findObjectsByNamedSqlAsJSON(Connection conn,
String sSql,
Map<String,Object> values,
String[] fieldnames)
执行一个带命名参数的查询并返回JSONArray
|
static com.alibaba.fastjson.JSONArray |
findObjectsByNamedSqlAsJSON(Connection conn,
String sSql,
Map<String,Object> values,
String[] fieldnames,
int pageNo,
int pageSize)
执行一个带命名参数的查询并返回JSONArray
|
static List<Object[]> |
findObjectsBySql(Connection conn,
String sSql) |
static List<Object[]> |
findObjectsBySql(Connection conn,
String sSql,
List<Object> values) |
static List<Object[]> |
findObjectsBySql(Connection conn,
String sSql,
Object value) |
static List<Object[]> |
findObjectsBySql(Connection conn,
String sSql,
Object[] values) |
static List<Object[]> |
findObjectsBySql(Connection conn,
String sSql,
Object[] values,
int pageNo,
int pageSize)
执行一个带参数的分页查询,这个是完全基于jdbc实现的,对不同的数据库来说效率差别可能很大
|
static com.alibaba.fastjson.JSONObject |
getObjectAsJSON(Connection conn,
String sSql) |
static com.alibaba.fastjson.JSONObject |
getObjectAsJSON(Connection conn,
String sSql,
Map<String,Object> values) |
static com.alibaba.fastjson.JSONObject |
getObjectAsJSON(Connection conn,
String sSql,
Map<String,Object> values,
String[] fieldnames) |
static com.alibaba.fastjson.JSONObject |
getObjectAsJSON(Connection conn,
String sSql,
Object[] values) |
static com.alibaba.fastjson.JSONObject |
getObjectAsJSON(Connection conn,
String sSql,
Object[] values,
String[] fieldnames) |
static Object |
getScalarObjectQuery(Connection conn,
String sSql) |
static Object |
getScalarObjectQuery(Connection conn,
String sSql,
Map<String,Object> values)
执行一个标量查询
|
static Object |
getScalarObjectQuery(Connection conn,
String sSql,
Object value) |
static Object |
getScalarObjectQuery(Connection conn,
String sSql,
Object[] values) |
static Object[] |
getSingleRow(Connection conn,
String sSql) |
static Object[] |
getSingleRow(Connection conn,
String sSql,
Map<String,Object> values) |
static Object[] |
getSingleRow(Connection conn,
String sSql,
Object value) |
static Object[] |
getSingleRow(Connection conn,
String sSql,
Object[] values) |
static String |
mapColumnNameToField(String colName)
已过时。
|
static String[] |
mapColumnsNameToFields(List<String> colNames) |
static Long |
queryTotalRows(Connection conn,
String sSql,
Map<String,Object> values)
将sql语句转换为查询总数的语句,
输入的语句为不带分页查询的语句,对于oracle来说就是where中没有rowunm,Mysql语句中没有limitDB2中没有fetch等等
|
static Long |
queryTotalRows(Connection conn,
String sSql,
Object[] values)
将sql语句转换为查询总数的语句,
输入的语句为不带分页查询的语句,对于oracle来说就是where中没有rowunm,Mysql语句中没有limitDB2中没有fetch等等
|
static void |
setQueryStmtParameters(PreparedStatement stmt,
List<Object> paramObjs) |
static void |
setQueryStmtParameters(PreparedStatement stmt,
List<String> paramsName,
Map<String,Object> paramObjs) |
static void |
setQueryStmtParameters(PreparedStatement stmt,
Object[] paramObjs) |
public static Object callFunction(Connection conn, String procName, int sqlType, Object... paramObjs) throws SQLException
conn - 数据库链接procName - procNamesqlType - 返回值类型paramObjs - paramObjsSQLException - SQLExceptionpublic static boolean callProcedure(Connection conn, String procName, Object... paramObjs) throws SQLException
conn - 数据库链接procName - procNameparamObjs - procNameSQLException - SQLExceptionpublic static boolean doExecuteSql(Connection conn, String sSql) throws SQLException
conn - connsSql - sSqlSQLException - SQLExceptionpublic static void setQueryStmtParameters(PreparedStatement stmt, Object[] paramObjs) throws SQLException
SQLExceptionpublic static void setQueryStmtParameters(PreparedStatement stmt, List<Object> paramObjs) throws SQLException
SQLExceptionpublic static void setQueryStmtParameters(PreparedStatement stmt, List<String> paramsName, Map<String,Object> paramObjs) throws SQLException
SQLExceptionpublic static int doExecuteSql(Connection conn, String sSql, Object[] values) throws SQLException
SQLExceptionpublic static int doExecuteNamedSql(Connection conn, String sSql, Map<String,Object> values) throws SQLException
SQLExceptionpublic static com.alibaba.fastjson.JSONObject fetchResultSetRowToJSONObject(ResultSet rs, String[] fieldnames) throws SQLException, IOException
public static com.alibaba.fastjson.JSONArray fetchResultSetToJSONArray(ResultSet rs, String[] fieldnames) throws SQLException, IOException
@Deprecated public static String mapColumnNameToField(String colName)
public static com.alibaba.fastjson.JSONArray findObjectsAsJSON(Connection conn, String sSql, Object[] values, String[] fieldnames) throws SQLException, IOException
conn - 数据库连接sSql - sql语句,这个语句必须用命名参数values - 命名参数对应的变量fieldnames - 字段名称作为json中Map的key,没有这个参数的函数会自动从sql语句中解析字段名作为json中map的SQLException - SQLExceptionIOException - IOExceptionpublic static com.alibaba.fastjson.JSONObject getObjectAsJSON(Connection conn, String sSql, Object[] values, String[] fieldnames) throws SQLException, IOException
public static com.alibaba.fastjson.JSONObject getObjectAsJSON(Connection conn, String sSql, Object[] values) throws SQLException, IOException
public static com.alibaba.fastjson.JSONObject getObjectAsJSON(Connection conn, String sSql) throws SQLException, IOException
public static com.alibaba.fastjson.JSONObject getObjectAsJSON(Connection conn, String sSql, Map<String,Object> values, String[] fieldnames) throws SQLException, IOException
public static com.alibaba.fastjson.JSONObject getObjectAsJSON(Connection conn, String sSql, Map<String,Object> values) throws SQLException, IOException
public static com.alibaba.fastjson.JSONArray findObjectsAsJSON(Connection conn, String sSql, Object[] values) throws SQLException, IOException
public static com.alibaba.fastjson.JSONArray findObjectsAsJSON(Connection conn, String sSql) throws SQLException, IOException
public static com.alibaba.fastjson.JSONArray findObjectsAsJSON(Connection conn, String sSql, Object value) throws SQLException, IOException
public static com.alibaba.fastjson.JSONArray findObjectsAsJSON(Connection conn, String sSql, Object value, String[] fieldnames) throws SQLException, IOException
public static com.alibaba.fastjson.JSONArray findObjectsByNamedSqlAsJSON(Connection conn, String sSql, Map<String,Object> values, String[] fieldnames) throws SQLException, IOException
conn - connsSql - sSqlvalues - valuesfieldnames - 对字段重命名SQLException - SQLExceptionIOException - IOExceptionpublic static com.alibaba.fastjson.JSONArray findObjectsByNamedSqlAsJSON(Connection conn, String sSql, Map<String,Object> values) throws SQLException, IOException
public static String fetchClobString(Clob clob) throws IOException
IOExceptionpublic static byte[] fetchBlobBytes(Blob blob) throws IOException
IOExceptionpublic static String fetchBlobAsBase64(Blob blob) throws IOException
IOExceptionpublic static List<Object[]> fetchResultSetToObjectsList(ResultSet rs) throws SQLException, IOException
public static Object[] fetchResultSetRowToObjects(ResultSet rs) throws SQLException, IOException
public static List<Object[]> findObjectsBySql(Connection conn, String sSql, Object[] values) throws SQLException, IOException
public static List<Object[]> findObjectsBySql(Connection conn, String sSql, List<Object> values) throws SQLException, IOException
public static List<Object[]> findObjectsBySql(Connection conn, String sSql, Object value) throws SQLException, IOException
public static List<Object[]> findObjectsBySql(Connection conn, String sSql) throws SQLException, IOException
public static List<Object[]> findObjectsByNamedSql(Connection conn, String sSql, Map<String,Object> values) throws SQLException, IOException
public static Object[] getSingleRow(Connection conn, String sSql, Map<String,Object> values) throws SQLException, IOException
public static Object[] getSingleRow(Connection conn, String sSql, Object[] values) throws SQLException, IOException
public static Object[] getSingleRow(Connection conn, String sSql) throws SQLException, IOException
public static Object[] getSingleRow(Connection conn, String sSql, Object value) throws SQLException, IOException
public static List<Object> fetchSingleColumn(List<Object[]> rsDatas, int columnIndex)
public static List<String> fetchSingleColumnAsString(List<Object[]> rsDatas, int columnIndex)
public static List<String> fetchSingleColumnAsString(List<Object[]> rsDatas)
public static Object getScalarObjectQuery(Connection conn, String sSql, Map<String,Object> values) throws SQLException, IOException
conn - 数据库链接sSql - sql 语句values - 参数SQLException - SQLExceptionIOException - SQLExceptionpublic static Object getScalarObjectQuery(Connection conn, String sSql, Object[] values) throws SQLException, IOException
public static Object getScalarObjectQuery(Connection conn, String sSql) throws SQLException, IOException
public static Object getScalarObjectQuery(Connection conn, String sSql, Object value) throws SQLException, IOException
public static Long queryTotalRows(Connection conn, String sSql, Object[] values) throws SQLException, IOException
conn - connsSql - sSqlvalues - 参数应该都在条件语句中,如果标量子查询中也有参数可能会有SQLException异常SQLException - 如果标量子查询中也有参数可能会有SQLException异常IOException - 这个查询应该不会有这个异常public static Long queryTotalRows(Connection conn, String sSql, Map<String,Object> values) throws SQLException, IOException
conn - connsSql - sSqlvalues - 命名参数SQLException - 这个查询应该不会有这个异常IOException - 这个查询应该不会有这个异常public static List<Object[]> findObjectsBySql(Connection conn, String sSql, Object[] values, int pageNo, int pageSize) throws SQLException, IOException
conn - 数据库连接sSql - sql语句,这个语句必须用命名参数values - 命名参数对应的变量pageNo - 第几页pageSize - 每页大小 ,小于1 为不分页SQLException - SQLExceptionIOException - IOExceptionpublic static com.alibaba.fastjson.JSONArray findObjectsAsJSON(Connection conn, String sSql, Object[] values, String[] fieldnames, int pageNo, int pageSize) throws SQLException, IOException
conn - 数据库连接sSql - sql语句,这个语句必须用命名参数values - 命名参数对应的变量fieldnames - 对字段重命名pageNo - 第几页pageSize - 每页大小 ,小于1 为不分页
字段名称作为json中Map的key,没有这个参数的函数会自动从sql语句中解析字段名作为json中map的SQLException - SQLExceptionIOException - IOExceptionpublic static com.alibaba.fastjson.JSONArray findObjectsAsJSON(Connection conn, String sSql, Object[] values, int pageNo, int pageSize) throws SQLException, IOException
conn - 数据库连接sSql - sql语句,这个语句必须用命名参数values - 命名参数对应的变量pageNo - 第几页pageSize - 每页大小 ,小于1 为不分页
字段名称作为json中Map的key,没有这个参数的函数会自动从sql语句中解析字段名作为json中map的SQLException - SQLExceptionIOException - IOExceptionpublic static List<Object[]> findObjectsByNamedSql(Connection conn, String sSql, Map<String,Object> values, int pageNo, int pageSize) throws SQLException, IOException
conn - 数据库连接sSql - sql语句,这个语句必须用命名参数values - 命名参数对应的变量pageNo - 第几页pageSize - 每页大小 ,小于1 为不分页SQLException - SQLExceptionIOException - IOExceptionpublic static com.alibaba.fastjson.JSONArray findObjectsByNamedSqlAsJSON(Connection conn, String sSql, Map<String,Object> values, String[] fieldnames, int pageNo, int pageSize) throws SQLException, IOException
conn - 数据库连接sSql - sql语句,这个语句必须用命名参数values - 命名参数对应的变量fieldnames - 对字段重命名
对字段重命名pageNo - 第几页pageSize - 每页大小 ,小于1 为不分页SQLException - SQLExceptionIOException - IOExceptionCopyright © 2025 江苏南大先腾信息产业股份有限公司. All rights reserved.