📄 dbaccesshelper.java
字号:
package com.set.db;
import java.util.List;
import org.apache.log4j.Logger;
import com.set.appframe.data.SearchResult;
/**
* Some handy methods to do the db operations
*
* @author tommy.zeng
*
*/
public class DBAccessHelper {
private static SQLBuilder builder = SQLBuilder.getInstance();
private static Logger log = Logger.getLogger(DBAccessHelper.class);
public static void updateCmd(List params, String sqlString)
throws DBAccessException {
DBUtils.update(sqlString, params);
}
public static void updateCmd(String sqlId, List params)
throws DBAccessException {
String sql = getSql(sqlId, "", null);
DBUtils.update(sql, params);
}
public static void updateCmd(String sqlId, List params, List replacement)
throws DBAccessException {
String sql = getSql(sqlId, "", replacement);
DBUtils.update(sql, params);
}
public static void batchUpdateCmd(String sqlId, List params)
throws DBAccessException {
String sql = getSql(sqlId, null, null);
DBUtils.batchUpdate(sql, params);
}
public static List QueryCmd(List params, String sqlId, String extraSql,
List replacement) throws DBAccessException {
String sql = getSql(sqlId, extraSql, replacement);
return DBUtils.queryForList(sql, params);
}
public static List QueryCmd(List params, String sqlId)
throws DBAccessException {
return QueryCmd(params, sqlId, null, null);
}
public static List QueryCmd(String sqlId, List params)
throws DBAccessException {
return QueryCmd(params, sqlId, null, null);
}
public static List QueryCmd(List params, String sqlId, String extraSql)
throws DBAccessException {
return QueryCmd(params, sqlId, extraSql, null);
}
public static List QueryCmd(List params, String sqlId, List replacement)
throws DBAccessException {
return QueryCmd(params, sqlId, null, replacement);
}
public static SearchResult pagedQuery(List params, String sqlId,
String extraSql, int page, int pageSize) throws DBAccessException {
String sql = getSql(sqlId, extraSql, null);
return DBUtils.getSearchResult(sql, params, page, pageSize);
}
public static SearchResult pagedQuery(String sqlFile, List params,
int intPageSize, int intPageNo) throws DBAccessException {
return pagedQuery(sqlFile, params, intPageSize, intPageNo, null, null);
}
public static SearchResult pagedQuery(String sqlFile, List params,
int intPageSize, int intPageNo, String extraSql)
throws DBAccessException {
return pagedQuery(sqlFile, params, intPageSize, intPageNo, null,
extraSql);
}
public static SearchResult pagedQuery(String sqlFile, List params,
int intPageSize, int intPageNo, List replacement)
throws DBAccessException {
return pagedQuery(sqlFile, params, intPageSize, intPageNo, replacement,
null);
}
public static SearchResult pagedQuery(String sqlFile, List params,
int intPageSize, int intPageNo, List replacement, String extraSql)
throws DBAccessException {
String sql = getSql(sqlFile, extraSql, replacement);
System.out.println("---"+sql);
return DBUtils.getSearchResult(sql, params, intPageNo, intPageSize);
}
public static List directPagedQuery(List params, String sqlId,
String extraSql, int page, int pageSize) throws DBAccessException {
String sql = getSql(sqlId, extraSql, null);
return DBUtils.pagedQueryForList(sql, params, page, pageSize);
}
public static List directPagedQuery(List params, String sqlId, int page,
int pageSize) throws DBAccessException {
return directPagedQuery(params, sqlId, null, page, pageSize);
}
public static List queryTop(List params, String sqlId, int top)
throws DBAccessException {
return directPagedQuery(params, sqlId, 1, top);
}
private static String getSql(String sqlId, String extraSql, List replacement) {
String sql = builder.getStatement(sqlId, extraSql, replacement);
return sql;
}
public static List QueryCmdSQL(List param, String sqlString) {
return DBUtils.queryForList(sqlString, param);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -