0

Client:

for(int j=0;j<prod10.length;j++){
            String ret_val ="";
            bean.setProd10(prod10[j]);
            ret_val=build.saveRSupplier(bean);

        }

DAO:

if(rs.next()){
                String sum=rs.getString("max(patient_no)+1");
                String q7="insert into new8(ok, reference)"
                        + " values('"+sum+"','"+purid10+"')";
                PreparedStatement p7 = con.prepareStatement(q7);
                int s7 = p7.executeUpdate();        
            }

if i put value in array then by using prod10 it set the length and array of data are stored in the database but if i do not put value in array null point exception occur,this should not have to happen what i should have to do for this

2

1 Answer 1

2

I presume your prod10 array is null. Have a null check before the for loop.

if(null != prod10) {
for(int j=0;j<prod10.length;j++){
            String ret_val ="";
            bean.setProd10(prod10[j]);
            ret_val=build.saveRSupplier(bean);

        }
}
Sign up to request clarification or add additional context in comments.

1 Comment

@scor. You are welcome. You can accept my answer if it worked for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.