Answer the question
In order to leave comments, you need to log in
Why does the request fail because of the foreign key?
Client database:
Gender database:
I am running a query:
INSERT INTO client (FirstName, LastName, Patronymic, Birthday, RegistrationDate, Email, Phone, GenderCode, PhotoPath) VALUES ('111', '111', '111', '1999-10-10', '2021-04-14 09:54:49', '111', '111', 'м', '111')
public static ResultSet executeQuery (String sql) {
ResultSet resultSet = null;
System.out.println(sql);
try {
PreparedStatement preparedStatement = connection.prepareStatement(sql);
if (sql.contains("SELECT")) {
resultSet = preparedStatement.executeQuery();
} else {
preparedStatement.executeUpdate();
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return resultSet;
}
Answer the question
In order to leave comments, you need to log in
You don't have an entry in the gender table with Code = 'm'.
Therefore, the write restriction to the associated GenderCode field is triggered.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question