The problem is this: I have a table in the database with a field position which receives integer values, then I load a list with the data of my table, now I need that when inserting a new record in the position 1 and if position 1 already exists in the database, go to number 2 and if there is 2, go to 3 and so on. All this with java.
public String accionRecorre() throws Exception {
lstSecciones=adminConfiguracionAsociadosDao.getLstMostrarSecciones();
int indice=Integer.parseInt(request.getParameter("tfIndex"));
for(int i=0; i<lstSecciones.size(); i++){
posInicial=lstSecciones.get(i).getIndex();
if(indice==posInicial){
posInicial++; //es en esta parte donde no sé cómo condicionar
}
adminConfiguracionAsociadosDao.insertarSeccion(idAsociado,nombre, visible, posInicial, estado);
return SUCCESS;
}