-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jdbc-intro homework #32
base: main
Are you sure you want to change the base?
Conversation
} | ||
return book; | ||
|
||
} catch (SQLException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch (SQLException e) { | |
} catch (Exception e) { |
|
||
@Override | ||
public List<Book> findAll() { | ||
String sql = "SELECT * FROM books WHERE is_deleted = false"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String sql = "SELECT * FROM books WHERE is_deleted = false"; | |
String sql = "SELECT * FROM books WHERE is_deleted = FALSE"; |
public List<Book> findAll() { | ||
String sql = "SELECT * FROM books WHERE is_deleted = false"; | ||
try (Connection connection = ConnectionUtil.getConnection(); | ||
PreparedStatement statement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PreparedStatement statement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { | |
PreparedStatement statement = connection.prepareStatement(sql)) { |
public Optional<Book> findById(Long id) { | ||
String sql = "SELECT * FROM books WHERE id = ? AND is_deleted = FALSE"; | ||
try (Connection connection = ConnectionUtil.getConnection(); | ||
PreparedStatement statement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PreparedStatement statement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { | |
PreparedStatement statement = connection.prepareStatement(sql)) { |
|
||
@Override | ||
public Book update(Book book) { | ||
String sql = "UPDATE books SET title = ?, price = ? WHERE id = ?;"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_deleted
String title = resultSet.getString("title"); | ||
BigDecimal price = resultSet.getBigDecimal("price"); | ||
return new Book(id, title, price); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.