SQL语句的bug都修完了
This commit is contained in:
@@ -67,9 +67,9 @@ public class BookAdder extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getBookMaxID() throws SQLException {
|
public int getBookMaxID() throws SQLException {
|
||||||
ResultSet rs = connector.executeQuery("SELECT MAX(book_id) FROM books;");
|
ResultSet rs = connector.executeQuery("SELECT MAX(book_id) AS max_book_id FROM books;");
|
||||||
rs.next();
|
rs.next();
|
||||||
return rs.getInt("MAX(book_id)");
|
return rs.getInt("max_book_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation() {
|
public void setLocation() {
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ public class StudentAdder extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getStudentMaxID() throws SQLException {
|
public int getStudentMaxID() throws SQLException {
|
||||||
ResultSet rs = connector.executeQuery("SELECT MAX(student_id) FROM students;");
|
ResultSet rs = connector.executeQuery("SELECT MAX(student_id) AS max_student_id FROM students;");
|
||||||
rs.next();
|
rs.next();
|
||||||
return rs.getInt("MAX(student_id)");
|
return rs.getInt("max_student_id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,11 +104,11 @@ public class SearchDIalog extends JDialog {
|
|||||||
|
|
||||||
private String SQLExeMaker(String table) {
|
private String SQLExeMaker(String table) {
|
||||||
if (table.equals("books")) {
|
if (table.equals("books")) {
|
||||||
return "SELECT * FROM `books` WHERE `book_id` = " + idInt + ";";
|
return "SELECT * FROM books WHERE book_id = " + idInt + ";";
|
||||||
} else if (table.equals("students")) {
|
} else if (table.equals("students")) {
|
||||||
return "SELECT * FROM `students` WHERE `student_id` = " + idInt + ";";
|
return "SELECT * FROM students WHERE student_id = " + idInt + ";";
|
||||||
} else if (table.equals("rents")) {
|
} else if (table.equals("rents")) {
|
||||||
return "SELECT * FROM `rents` WHERE `book_id` = " + idInt + ";";
|
return "SELECT * FROM rents WHERE book_id = " + idInt + ";";
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user