Q:

java program not getting inside while loop for unique row result set

I have a result set that should contain 1 row (I have tested this). My program is not getting inside the while(rs2.next()) loop, I have noticed this after debugging. that's why I'm getting SQLException : not all variables bound.
ResultSet constitues = cnx.createStatement().executeQuery(Request.getConstitues());

            while(constitues.next()){
                PreparedStatement ps = cnx.prepareStatement(Request.setNewConstitue());
                PreparedStatement ps2 = cnx.prepareStatement(Request.getDossierFromNumeroParcelle());

                ps2.setInt(1, constitues.getInt("NUM_ORDRE"));
                ps2.setInt(2, constitues.getInt("NUM_PARCELLE"));

                        //rs2 contains one row
                ResultSet rs2 = ps2.executeQuery();
                        // Program is not entering this loop
                while(rs2.next()){
                   ps.setInt(1, rs2.getInt("NUM_DOSSIER"));
                   ps.setString(2, rs2.getString("INDICE"));
                   ps.setString(3, constitues.getString("OBSERVATIONS"));
                   ps.setInt(4, constitues.getInt("TYPE_CONSISTANCE"));
                }

                ps.executeUpdate();
                rs2.close();
                ps.close();

            }    

Request.getConstitues() is :  
 select * from PARC_CONSTITUES

Request.setNewConstitue()  is :  
Insert into CONSTITUE(NUM_DOSSIER,INDICE,Observation,CODE_CONSISTANCE) values(?,?,?,?)

Request.getDossierFromNumeroParcelle() is :    
select NUM_DOSSIER,INDICE from PARC_PARCELLES where num_ordre = ? and num_parcelle= ?

Why program is not getting inside the while loop ?

A:

i suspect data is not available in DB or its failing to retrieve from DB.
but any way check this condition before you go for while loop
boolean isEmpty = ! rs.first();

and print isEmpty for debugging.
so use something like this 
if(!isEmpty)
{
 while(rs2.next()){
                   ps.setInt(1, rs2.getInt("NUM_DOSSIER"));
                   ps.setString(2, rs2.getString("INDICE"));
                   ps.setString(3, constitues.getString("OBSERVATIONS"));
                   ps.setInt(4, constitues.getInt("TYPE_CONSISTANCE"));
}
            }

