[英]How to use ResultSet: absolute(int row) in java and dispaly retrieved rows in tabular format through jsp using jstl
I want to retrieve some specific rows from ResultSet by using absolute(int row) method .I have retrieved all the rows in tabular format by following code: 我想通过使用absolute(int row)方法从ResultSet中检索一些特定的行。我已经通过以下代码以表格格式检索了所有行:
public String[][] reference() {
String a[][]=new String[46][2];
int i=0;
try
{
con = getConnection();
stmt = con.createStatement(rs.TYPE_SCROLL_SENSITIVE,rs.CONCUR_READ_ONLY);
String sql="select logtime,beam_current from INDUS2_BDS.dbo.DCCT where logtime between '2014-10-10 07:17:00' and '2014-10-10 08:46:00'"+
"and (beam_current like '%9.96' or beam_current like '%9.97' or beam_current like '%9.98' or beam_current like '%9.99' or beam_current like '%0' or beam_current like '%_0.01' or beam_current like '%_0.02' or beam_current like '%_0.03' or beam_current like '%_0.04' or beam_current like '%_0.05' or beam_current like '%_0.06')";
stmt.executeQuery(sql);
rs = stmt.getResultSet();
while(rs.next())
{
for(int j=0; j<2; j++)
{
a[i][j] = rs.getString(j+1);
}
i++;
}
}
catch( Exception e )
{
System.out.println("\nException "+e);
}
finally
{
closeConnection(stmt, rs, con);
}
return a;
Now I only want to retrieve only 3,4,11,13,23,27,28 rows in-spite of all.How to do that? 现在我只想检索3、4、11、13、23、27、28行,但该怎么做呢?
Define int rowCounter=0;
定义
int rowCounter=0;
before the while
and increase it in the end of the while
body. 在之前
while
,增加它的结束while
体。
Add a check if (rowCounter==3 || rowCounter==4 ...) { //do your logic}
添加检查
if (rowCounter==3 || rowCounter==4 ...) { //do your logic}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.