I am inserting rows into the columns of oracle table that I created manually on the DB with the number of column names and order that in the XML file. The XML is considered as a config file,so the users can manage the columns and update them as per business needs. My java code reads the XML file and pulls the column names from XML and through Document(content mgmt technology)API.
I can extract the values of those columns and insert the rows into the DB table. I am fine till here, Since my query runs on the timer for three hour this query runs,due to this I am getting duplicate values into the DB table--as the same old query run and the old result are pushed into DB.
I need to avoid this, it would be great if you someone can help me with this.
Code:
String rObjectIdCheck = null;
pSelect = dbConn.prepareStatement("select r_object_id from financial_data");
ResultSet rsSelect = pSelect.executeQuery();
while(rsSelect.next()){
rObjectIdCheck =(String)rsSelect.getObject("r_object_id");
System.out.println("The OBJECTID from DB is:"+rObjectIdCheck);
System.out.println("The ObjectID from DCTM extract:"+rObjectID);
if (rObjectIdCheck!=rObjectID) {
pStmt = dbConn.prepareStatement("insert into financial_data ("+sbAttrName.toString()+")" + "values" +"("+sbAttrValue.toString()+")");
pStmt.addBatch();
pStmt.executeBatch();
}
}
sbAttrValue.delete(0, iSBValue);
sbAttrName.delete(0,iSBName);
}