新增错误提示
This commit is contained in:
parent
55e61ca5fe
commit
1ce4b97fd6
@ -215,6 +215,9 @@ public class DatabaseService {
|
|||||||
int count = rs.getInt(1);
|
int count = rs.getInt(1);
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
if (count>1){
|
||||||
|
throw new SQLException("Duplicate project found");
|
||||||
|
}
|
||||||
String updateSql = "UPDATE projects SET summary = ?, description = ?, keywords = ?, type = ?, collaborators = ?, link = ?, time = ? WHERE title = ? AND user_id = (SELECT id FROM users WHERE username = ?)";
|
String updateSql = "UPDATE projects SET summary = ?, description = ?, keywords = ?, type = ?, collaborators = ?, link = ?, time = ? WHERE title = ? AND user_id = (SELECT id FROM users WHERE username = ?)";
|
||||||
try (PreparedStatement updateStmt = conn.prepareStatement(updateSql)) {
|
try (PreparedStatement updateStmt = conn.prepareStatement(updateSql)) {
|
||||||
updateStmt.setString(1, project.getSummary());
|
updateStmt.setString(1, project.getSummary());
|
||||||
|
|||||||
@ -151,6 +151,7 @@ public class ProjectBean implements Serializable {
|
|||||||
context.addMessage("saveButton", new FacesMessage(FacesMessage.SEVERITY_INFO, "Submission Succeeded", null));
|
context.addMessage("saveButton", new FacesMessage(FacesMessage.SEVERITY_INFO, "Submission Succeeded", null));
|
||||||
loadAllKeywords();
|
loadAllKeywords();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
context.addMessage("saveButton", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Submission Failed", null));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return "project";
|
return "project";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user