如何在java中使用ResultSet:absolute(int行),并使用jstl通过jsp以表格格式显示检索到的行
我想使用绝对(int row)方法从ResultSet中检索某些特定行。我已通过以下代码检索了表格格式的所有行:如何在java中使用ResultSet:absolute(int行),并使用jstl通过jsp以表格格式显示检索到的行,java,jsp,cursor,resultset,Java,Jsp,Cursor,Resultset,我想使用绝对(int row)方法从ResultSet中检索某些特定行。我已通过以下代码检索了表格格式的所有行: public String[][] reference() { String a[][]=new String[46][2]; int i=0; try { con = getConnection(); stmt = con.createStatemen
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;
公共字符串[][]引用(){
字符串a[][]=新字符串[46][2];
int i=0;
尝试
{
con=getConnection();
stmt=con.createStatement(rs.TYPE\u SCROLL\u敏感,rs.CONCUR\u只读);
String sql=“从industs2_BDS.dbo.DCCT中选择日志时间、束流,其中日志时间介于‘2014-10-10 07:17:00’和‘2014-10-10 08:46:00’之间”+
“和(束流如'%9.96'或束流如'%9.97'或束流如'%9.98'或束流如'%9.99'或束流如'%0'或束流如'%0.01'或束流如'%0.02'或束流如'%0.03'或束流如'%0.04'或束流如'%0.05'或束流如'%0.06')”;
执行程序(sql);
rs=stmt.getResultSet();
while(rs.next())
{
对于(int j=0;j定义int rowCounter=0;
在while
之前,并在while
正文末尾增加它
添加一个检查如果(rowCounter==3 | | rowCounter==4…{//do your logic}
如何在浏览器上打印该ResultSet absolute()值,即当我执行以下操作时(rowCounter==3 | | rowCounter==4…{rs.absolute(3);rs.absolute(4)}返回rs,那么我将SQLServerResultSet:1作为输出,而不是特定的行,我无法打印这些行。