本文整理汇总了Java中ro.nextreports.engine.util.QueryUtil.getColumns方法的典型用法代码示例。如果您正苦于以下问题:Java QueryUtil.getColumns方法的具体用法?Java QueryUtil.getColumns怎么用?Java QueryUtil.getColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ro.nextreports.engine.util.QueryUtil
的用法示例。
在下文中一共展示了QueryUtil.getColumns方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllColumnTypesForReport
import ro.nextreports.engine.util.QueryUtil; //导入方法依赖的package包/类
public static List<String> getAllColumnTypesForReport(String sql) throws Exception {
List<String> columnTypes = new ArrayList<String>();
Connection con = null;
String md5Key = Cache.getColumnsKey(sql);
List<NameType> result = Cache.getColumns(md5Key);
if (result != null) {
return ReportUtil.getColumnTypes(result);
}
try {
con = Globals.createTempConnection(
DefaultDataSourceManager.getInstance().getConnectedDataSource());
QueryUtil qu = new QueryUtil(con, Globals.getDialect());
// get parameters definition from system
Map<String, QueryParameter> params = new HashMap<String, QueryParameter>();
ParameterManager paramManager = ParameterManager.getInstance();
List<String> paramNames = paramManager.getParameterNames();
for (String paramName : paramNames) {
QueryParameter param = paramManager.getParameter(paramName);
if (param == null) {
throw new Exception(I18NSupport.getString("parameter.undefined", paramName));
}
params.put(paramName, param);
}
List <NameType> columns = qu.getColumns(sql, params);
columnTypes = ReportUtil.getColumnTypes(columns);
Cache.setColumns(md5Key, columns);
} finally {
if (con != null) {
con.close();
}
}
return columnTypes;
}
示例2: getAllColumnsForReport
import ro.nextreports.engine.util.QueryUtil; //导入方法依赖的package包/类
public static List<NameType> getAllColumnsForReport(String sql) throws Exception {
List<NameType> columnTypes = new ArrayList<NameType>();
String md5Key = Cache.getColumnsKey(sql);
List<NameType> result = Cache.getColumns(md5Key);
if (result != null) {
return result;
}
Connection con = null;
try {
con = Globals.createTempConnection(
DefaultDataSourceManager.getInstance().getConnectedDataSource());
QueryUtil qu = new QueryUtil(con, Globals.getDialect());
// get parameters definition from system
Map<String, QueryParameter> params = new HashMap<String, QueryParameter>();
ParameterManager paramManager = ParameterManager.getInstance();
List<String> paramNames = paramManager.getParameterNames();
for (String paramName : paramNames) {
QueryParameter param = paramManager.getParameter(paramName);
if (param == null) {
throw new Exception(I18NSupport.getString("parameter.undefined", paramName));
}
params.put(paramName, param);
}
columnTypes = qu.getColumns(sql, params);
Cache.setColumns(md5Key, columnTypes);
} finally {
if (con != null) {
con.close();
}
}
return columnTypes;
}
示例3: getColumnTypeForReportColumn
import ro.nextreports.engine.util.QueryUtil; //导入方法依赖的package包/类
public static String getColumnTypeForReportColumn(String sql, String column) throws Exception {
Connection con = null;
String md5Key = Cache.getColumnsKey(sql);
List<NameType> result = Cache.getColumns(md5Key);
if (result != null) {
return getColumnTypeByName(column, result);
}
try {
con = Globals.createTempConnection(
DefaultDataSourceManager.getInstance().getConnectedDataSource());
QueryUtil qu = new QueryUtil(con, Globals.getDialect());
// get parameters definition from system
Map<String, QueryParameter> params = new HashMap<String, QueryParameter>();
ParameterManager paramManager = ParameterManager.getInstance();
List<String> paramNames = paramManager.getParameterNames();
for (String paramName : paramNames) {
QueryParameter param = paramManager.getParameter(paramName);
if (param == null) {
throw new Exception(I18NSupport.getString("parameter.undefined", paramName));
}
params.put(paramName, param);
}
List<NameType> columns = qu.getColumns(sql, params);
Cache.setColumns(md5Key, columns);
return getColumnTypeByName(column, columns);
} finally {
if (con != null) {
con.close();
}
}
}