Update annotation : JDBC Annotation « Database « Java Tutorial






The Update annotation is used to decorate a method specifying an SQL update statement.

The method's return value can be an int or void.

Only if the return value type is int will the update count be returned.

ElementTypeAccessibility
sql or valueStringThe SQL statement to be executed
keysGenerated KeysIndicates if autogenerated keys are returned. The default value is GeneratedKeys.NO_KEYS_RETURNED


import java.sql.BaseQuery;
import java.sql.DataSet;
import java.sql.Select;
public interface UserQueries extends BaseQuery {


    // Delete user
    @Update ("DELETE Users WHERE firstName={firstName}" +
             "AND lastName={lastName}")
    int deleteUser (String firstName, String lastName);
}








20.25.JDBC Annotation
20.25.1.JDBC Annotations
20.25.2.Update annotation