Hi All,
I am facing a problem in Using Update query in prepared statement. I am trying to update a huge set of records by using Prepared Statement in
JAVA
The Code is as follows:
statement5=connection.prepareStatement("update CHANNELINVENTORY set CHANNELCODE=?,LASTUPDATEON=sysdate where UPPER(ITEMCODE)=? and UPPER(SERIALNUMBER)=? ");
for(int j=0;j<channelInventoryDetails.size();j++){
String channelDetails=(String)channelInventoryDetails.get(j);
String[] channel=channelDetails.split("-");
statement5.setString(1,channel[0]);
statement5.setString(2,channel[1]);
statement5.setString(3,channel[2]);
if (j > 0 && j % 1000 == 0){
System.out.println("before addbatch-from if->"+j);
statement5.addBatch();
statement5.clearParameters();
statement5.executeBatch();
}else{
System.out.println("before addbatch-from else->"+j);
statement5.addBatch();
statement5.clearParameters();
}
}
In my present case i am trying to update around 3000 records, in my code after every 1000 records i am executing that batch , which is taking huge time ...nothing is coming its just hanging for huge time .. its just prints this ------------------->before addbatch-from if->1000 thats it
And in the DB there primary key constaints on both the (ITEMCODE+SERIALNUMBER) and there is a index on CHANNELCODE..
Please suggest me the changes...
Is this the right way to update huge data in the table ...or is there any other way to update huge data.