~weird bug fixed: head->desk

Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
Johannes Theiner 2019-04-25 07:00:50 +02:00
parent d91e4ad5f1
commit 61e9b4df54
1 changed files with 4 additions and 10 deletions

View File

@ -448,7 +448,7 @@ public class Database {
assert category != null;
try {
PreparedStatement statement = connection.prepareStatement("INSERT INTO " + book + "(isbn, title, description, " +
PreparedStatement statement = connection.prepareStatement("INSERT INTO book(isbn, title, description, " +
"price, year, publisher, category, image) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
statement.setLong(1, book.getIsbn());
statement.setString(2, book.getTitle());
@ -466,15 +466,9 @@ public class Database {
}
for (Author author : authors) {
//FIXME: Prepared Statement is broken, parameters are null, but they are not
String query = "INSERT INTO " + authorBook + " (author, book) VALUES (?, ?);";
String workingQuery = "INSERT INTO " + authorBook + " (author, book) VALUES (" + author.getId() + ", "+ lastId + ")";
PreparedStatement authorStatement = connection.prepareStatement(workingQuery);
//statement.setLong(1, author.getId());
//statement.setLong(2, lastId);
System.out.println(authorStatement);
System.out.println(author.getId());
System.out.println(lastId);
PreparedStatement authorStatement = connection.prepareStatement("INSERT INTO " + authorBook + " (author, book) VALUES (?, ?);");
authorStatement.setLong(1, author.getId());
authorStatement.setLong(2, lastId);
insertCount += authorStatement.executeUpdate();
}