I am getting BatchUpdateException while inserting data into PostgreSQl through file
The exception I get is:
Batch entry 0 {call PACKAGE_NAME.PROCEDURE_NAME()} was aborted. Call getNextException to see the cause
Source code is below :-
successMsg = getJdbcTemplate().batchUpdate("{call "+ packageName +"."+ procedureName +sb.toString(),new BatchPreparedStatementSetter(){
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException
{
String values = insertList.get(i);
String []valuesArray=values.split(",");
int parameterCount=ApplicationConstant.ONE;
for(int valueIndex=0;valueIndex<valuesArray.length;valueIndex++)
{
ps.setString(parameterCount++, String.valueOf(valuesArray[valueIndex])!=null?String.valueOf(valuesArray[valueIndex]).trim().replaceAll("@@@", ","):""); //added trim() in order to avoid blank space entry in DB.
}
if(financialMonth!=null&&!financialMonth.equals(""))
{
ps.setString(parameterCount++,"01-"+financialMonth);
}
ps.setInt(parameterCount++,loginBean.getUserId());
ps.setDate(parameterCount, null);
}
@Override
public int getBatchSize()
{
return insertList.size();
}
});