Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ResultSet class how to check if the column index exists?

807601Feb 23 2008 — edited Feb 23 2008
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...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2008
Added on Feb 23 2008
2 comments
2,620 views