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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
scor
  • 15
  • 6
  • I presume your `prod10` array is `null`. Have a null check before the for loop. – Zeeshan Sep 30 '15 at 13:38
  • 1
    possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – Mage Xy Sep 30 '15 at 13:45

1 Answers1

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);

        }
}
Zeeshan
  • 11,851
  • 21
  • 73
  • 98