Reputation: 1
I have written this and its working properly and data is saved in database but no statement is get executed after execute() statement. Please help me...
public static String addNewMember(MemberRegister member){ String message=null; try {
if(!(IsUserValid(member.getEmail()))){
conn=getConnection();
System.out.println("user not exist");
callStmt = conn.prepareCall("{call insertMember(?,?,?)}");
callStmt.setString(1, member.getCompanyName());
callStmt.setString(2, member.getEmail());
callStmt.setString(3, member.getPassword());
//register the OUT parameter before calling the stored procedure
System.out.println(callStmt.execute());
//read the OUT parameter now
message="Record added successfully";
}
else{
message="Record already exists";
}
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try {
if(callStmt != null)
callStmt.close();
if(conn != null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
System.out.println("Hello "+message);
return message;
}
Upvotes: 0
Views: 35
Reputation: 537
try using executeUpdate() method (because INSERT is a DML) which is inherited from PreparedStatement . It will return an int value and check the returned int value to see if it's executed or not.
executeUpdate() returns no. of rows affected.
If you want i can send a modified code.
Upvotes: 2