0

次のコードに従って:

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;
            }

As per the above codes, I'm trying to check if a char is equal to my resultset record. e.g. if A is equal to A, if date = date and name = name than do something.

But when I setText(String.valueOf(Secgrp)), no char is being inserted.

Please advice how can I retrieve a char e.g 'A' from resultSet.

4

1 に答える 1

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;
        }
于 2013-01-22T04:33:41.970 に答える