jdbc - Not validating result set size using Java -


this weird issue. know i'm making small mistake not able figure out in it.

i'm executing 1 query , has result set. first i'm validating if doesn't has records set 1 of dto attribute false. if has records, iterate , business.

rs = partypreparedstatement.executequery();  if(!rs.next()) { // has records, i'm checking ! operator make sure goes false or true.      purchasedto.setpoissued(false); } else {     while (rs.next()) { // has records, still not going execute business         // business here.                        break;     }                 } 

is design correct?

if data is returned ignoring first row.

the first call next() position resultset first row (if there data). don't row, call next() again (in while condition) ignoring first row completely.

how solve problem matter of taste. count number of rows processed:

if want process first row, don't need while begin with:

rs = partypreparedstatement.executequery();  if (rs.next()) {    purchasedto.setpoissued(true);    // process data here } else {    purchasedto.setpoissued(false); } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -