java - Select Specific value from multiple rows returned by Oracle database -


i trying compare specific value values returned database.
getting multiple rows storestaff trying compare 1 of values returned table..

contains() ,  equals()  

are not working.

string qry = "select employe_id storestaff post='admin'"; pstmnt = conn.preparestatement(qry); resultset rs2 = pstmnt.executequery(qry); if (rs2.next()) {     string aa = rs2.getstring("employe_id");      if (aa.contains(un.gettext())) {         this.aa = aa;         joptionpane.showmessagedialog(null, "exists");     } else {         joptionpane.showmessagedialog(null, "username doesn't exist");     } } 

can suggestt me better solution or can tell me better solution it?

if use if return first values, in case have use while, loop throw results, can check multiple results, instead can use :

boolean check = false; while (rs2.next()) {     string aa = rs2.getstring("employe_id");     if (aa.contains(un.gettext())) {         this.aa = aa;         check = true;//if value exist change variable true         break;       //and break loop     } }  //when end have check value, if true user exist else no if (check) {     joptionpane.showmessagedialog(null, "exists"); } else {     joptionpane.showmessagedialog(null, "username doesn't exist"); } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -