logMessage(Logger.MINOR,Logger.DB_WRITE, getClusterName()+" executing a prepared batch of a thousand instances, " + num + " so far ");
if (isMinorEnabled()) { logMessage(Logger.MINOR,Logger.DB_WRITE, getClusterName()+" executing a prepared batch of a thousand instances, " + num + " so far "); }
  protected void updateDB(Connection c, DeXMLable obj){    setStatus("Starting");    InstancesData data=(InstancesData)obj;    PreparedStatement instancePS, manifestPS;    try{      instancePS = getInstancePreparedStatement (c);      manifestPS = getManifestPreparedStatement (c);      logMessage(Logger.TRIVIAL,Logger.DB_WRITE,		 getClusterName()+" instance created prepared statements.");    }catch(SQLException e){      haltForError(Logger.DB_WRITE,"Could not create Statement",e);      return;    }    int num=0;    int unsuccessful=0;    Iterator iter=data.getInstancesIterator();    setStatus("Creating batch updates for instances...");    while(iter.hasNext()){      num++;      Instance part=(Instance)iter.next();      if(!updateAssetInstance(instancePS,part))	unsuccessful++;      if(part.hasManifest) {	if(!updateManifest(manifestPS,part))	  unsuccessful++;      }      if ((num +1) % 1000 == 0) {	try{	  logMessage(Logger.MINOR,Logger.DB_WRITE,		     getClusterName()+" executing a prepared batch of a thousand instances, " + num + " so far ");	  instancePS.executeBatch();	  manifestPS.executeBatch();	}catch(SQLException e){	  if(!dbConfig.getUniqueViolatedErrorCode().equals(e.getSQLState())){ 	    // this well happen, since the same asset UID may appear in multiple agents	    logMessage(Logger.WARNING,Logger.DB_WRITE,"While executing batch, got SQL Error - " + e);	    e.printStackTrace ();	  }	}      }      if(halt)return;    }    try{      logMessage(Logger.MINOR,Logger.DB_WRITE,		 getClusterName()+" executing the last prepared batch, " + num + " total instances done.");      instancePS.executeBatch();      manifestPS.executeBatch();    }catch(SQLException e){      if(!dbConfig.getUniqueViolatedErrorCode().equals(e.getSQLState())){ 	// this well happen, since the same asset UID may appear in multiple agents	logMessage(Logger.WARNING,Logger.DB_WRITE,"SQL Error - " + e);	e.printStackTrace ();      }    }    if(unsuccessful>0)      logMessage(Logger.WARNING,Logger.DB_WRITE,		 getClusterName()+" could not add "+unsuccessful+		 " instances(s)");    try {       instancePS.close();      manifestPS.close();     } catch(Exception e){      logMessage(Logger.WARNING,Logger.DB_WRITE,		 getClusterName()+" got exception closing prepared statement " + instancePS + 		 " or " + manifestPS +		 " - exception was : " + e);      e.printStackTrace ();    }    setStatus("Done");  }