我在java中有一个方法,它提供了一个包含各种列的表。其中一列是beam_current,其实数类型值为220. Now I want to display only those rows of the table where beam_current values are closest to 10,20,30..till 220.
为了做到这一点,我必须取一个变量并为其赋值10并用beam_current值减去它,并且我得到的最小/最小值应该在表中显示。有时在(rs)中运行for循环.next)例如
while(rs.next)
{
for(f=10;f<=220;f+10)`**//f+10 how to do in for?**`
{
variable=rs.getInt(2)`**//beam_current is second column**`
f-=variable;
code for least value of f`**//(how to code for it???)**`
}
}
但是我没有得到如何为这个内循环编码来检索所需的输出。
我检索表的代码是
public String[][] ref_Details() {
int i = 0;
String a[][] = new String[47][11];
try {
con = getConnection();
stmt = con.createStatement();
String sql = " select b.LOGTIME, b.beam_current, b.beam_energy,case when a.st1_vs1_bag1_onoff=0 then c.st1_vs1_bag1_rb ELSE 0 END as st1_vs1_bag1_rb ,CASE when a.st1_vs1_bag2_onoff=0 then c.st1_vs1_bag2_rb else '0' END as st1_vs1_bag2_rb ,CASE when a.st1_vs1_bag3_onoff=0 then c.st1_vs1_bag3_rb else '0' END as st1_vs1_bag3_rb ,CASE when a.st1_vs1_bag4_onoff=0 then c.st1_vs1_bag4_rb else '0' END as st1_vs1_bag4_rb ,CASE when a.st1_vs1_bag5_onoff=0 then c.st1_vs1_bag5_rb else '0' END as st1_vs1_bag5_rb ,CASE when a.st1_vs1_bag6_onoff=0 then c.st1_vs1_bag6_rb else '0' END as st1_vs1_bag6_rb , CASE when a.st1_vs1_bag7_onoff=0 then c.st1_vs1_bag7_rb else '0' END as st1_vs1_bag7_rb ,CASE when a.st1_vs1_bag8_onoff=0 then c.st1_vs1_bag8_rb else '0' END as st1_vs1_bag8_rb from INDUS2_BDS.dbo.DCCT b INNER JOIN (main_vacuum_analog c inner join main_vacuum_status a on c.logtime=a.logtime) ON a.LOGTIME = b.LOGTIME and ( b.beam_current like '%9.97' or b.beam_current like '%9.98' or b.beam_current like '%9.99' or b.beam_current like '%0' or b.beam_current like '%0.01' or b.beam_current like '%0.02' or b.beam_current like '%0.03' or b.beam_current like '%0.04' or b.beam_current like '%0.05' or b.beam_current like '%0.06')and b.logtime between '2014-10-10 07:17:00' and '2014-10-10 08:46:00'";
stmt.executeQuery(sql);
rs = stmt.getResultSet();
while (rs.next())
{
for (int j = 0; j < 11; j++) {
a[i][j] = rs.getString(j + 1);
}
i++;
}
} catch (Exception e) {
System.out.println("\nException " + e);
} finally {
closeConnection(stmt, rs, con);
}
return a;
}
现在我想只显示那些最接近10,20,30 ......或者220的行。