根据以下代码:
char Secgrp = 0;
try{
String a = (String) comboName.getSelectedItem();
String fill = "Select recDate, attendant, grp from log order by id DESC";
ps = conn.prepareStatement(fill);
rs = ps.executeQuery();
String x = cDate();
while (rs.next()){
java.sql.Date dDate = rs.getDate("recDate");
String bName = rs.getString("attendant");
char[] cbuf = new char[1];
rs.getCharacterStream("grp").read(cbuf);
char theValue = cbuf[0];
String grp = Character.toString(theValue);
if(x.equals(dDate.toString()) && group1 == theValue && a.equals(bName)){
Secgrp = theValue++ ;
}
else if(x.equals(dDate.toString()) && theValue > group1 && a.equals(bName))
{ Secgrp = theValue++;
}
else if(x.equals(dDate.toString()) && group1 > theValue && a.equals(bName))
{ Secgrp = group1;
}
根据上面的代码,我正在尝试检查char是否等于我的结果集记录。例如如果A等于A,如果date = date和name = name,则执行某些操作。
但是当我使用setText(String.valueOf(Secgrp))时,没有插入char。
请告知如何从resultSet中检索char,例如'A'。
答案 0 :(得分:0)
解决方案:在每个块之后添加中断
if(x.equals(dDate.toString()) && group1 == theValue && a.equals(bName)){
Secgrp = theValue++ ;
Break;
}
else if(x.equals(dDate.toString()) && theValue > group1 && a.equals(bName))
{ Secgrp = theValue++;
Break;
}
else if(x.equals(dDate.toString()) && group1 > theValue && a.equals(bName))
{ Secgrp = group1;
Break;
}