2 Replies Latest reply: Feb 23, 2008 5:34 PM by 807601 RSS

    ResultSet class how to check if the column index exists?

    807601
      Hi all. Can't you help me... How can I get the size of the certain ResultSet? Because when I am trying to get Column with index more than possible I am getting an sql error (no column exists) d:(
      ResultSet srs = stmt.executeQuery(sql);
      
              int a=1;
              int b=1;
              String s=null;
              while(srs.next()){
                   s=srs.getString(b);
                   while(! s.equals(null)){
                        System.out.println(b+" "+s);
                        b++;
                        s=srs.getString(b);
                   }            
                   a++;b=1;               
              }
      For example I have 8 columns, and when b++ makes b==9 the method getString(9) throws exception...