java - How to get boolean value by executing the Prepared Statement? -
i facing problem. have no idea correct or not.
actually, executing prepared statement query return true/false boolean. when query should executed executed successfully, return true boolean; return false.
what should do???
the code below:
string updatelistquery = "update recon_exception_etm_dcr set group_id = ?, assign_dt = sysdate recon_id = ? , upper(trim(reason_desc)) <> 'reconciled' , trunc(duty_date) = ? " ; try{ conn = connect.getconn(); getgroupnamestmt = conn.preparestatement(updatelistquery);
getgroupnamestmt.setstring(1, groupid); getgroupnamestmt.setstring(2, reconid); getgroupnamestmt.setstring(3, defformatdt); flag = getgroupnamestmt.execute(); flag = true; }catch(sqlexception e){ flag = false; e.printstacktrace(); }finally{ try{ conn.commit(); getgroupnamestmt.close(); conn.close(); }catch(sqlexception e){ e.printstacktrace(); }
for data manipulation language (dml) statement, such insert, update or delete can use executeupdate() returns number of rows updated, can useful when running update statement. in case not needed, since know how many records inserting.
int updatecount=pst.executeupdate(); if(updatecount>0) { flag=true; }
Comments
Post a Comment