问题描述
|
我有一个返回许多结果的SQL查询(不幸的是,结果数会有所不同)。目前,我将结果存储到arrayList中,如下所示:
ArrayList allTerms = new ArrayList();
try {
String selStmt = \"SELECT .... \";
stmt = conn.prepareStatement(selStmt);
result = stmt.executeQuery();
Object result_data;
while (result.next()) {
term = (((result_data = result.getObject(\"internal_code\"))==null || result.wasNull())?\" \":result_data.toString());
allTerms.add(term);
desc = (((result_data = result.getObject(\"external_representation\"))==null || result.wasNull())?\" \":result_data.toString());
allTerms.add(desc);
sorter = (((result_data = result.getObject(\"sorter\"))==null || result.wasNull())?\" \":result_data.toString());
allTerms.add(sorter);
sDate = (((result_data = result.getObject(\"sDate\"))==null || result.wasNull())?\" \":result_data.toString());
allTerms.add(sDate);
}
System.out.println(allTerms);
好的,所以当我运行它时,系统将打印:
[2011SP,Spring 2011,1,11-15-2010,2011SU,Summer 2011,01-15-2011,2011FL,Fall 2011,04-01-2011,2010Q2,CE Qtr 2 2010 Dec - Feb,2,08-01-2010,2011Q3,CE Qtr 3 2011 Mar - May,11-01-2010,2011Q4,CE Qtr 4 2011 Jun - Aug,02-01-2011,2011Q1,CE Qtr 1 2011 Sep-Nov,05-01-2011]
我不知道这是否是正确的方法,但是到目前为止它仍在工作,所以我现在想做的是使用allTerms arrayList将这些结果传输到HTML页面的各个部分。因此,例如:
<table class=\"t1\">
<tr>
<td><!--Here I would want to show all rows from the allTerms arrayList with a \"sorter\" of 1--></td>
</tr>
</table>
<table class=\"t2\">
<tr>
<td><!--Here I would want to show all rows from the allTerms arrayList with a \"sorter\" of 1 and a term of ....SU (where \'....\' is the year) --></td>
</tr>
</table>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)