Skip to content

Commit

Permalink
Changed
Browse files Browse the repository at this point in the history
  • Loading branch information
GlebPashko committed May 22, 2024
1 parent 2a2957f commit f6d476c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/java/mate/academy/dao/BookDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Optional<Book> findById(Long id) {
Book book = null;
String sql = "SELECT * FROM books WHERE id = ?";
try (Connection connection = ConnectionUtil.getConnections();
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
preparedStatement.setLong(1, id);
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
Expand All @@ -93,7 +93,7 @@ public List<Book> findAll() {
String sql = "SELECT * FROM books";

try (Connection connection = ConnectionUtil.getConnections();
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
ResultSet resultSet = preparedStatement.executeQuery();

while (resultSet.next()) {
Expand Down Expand Up @@ -150,7 +150,7 @@ public boolean deleteById(Long id) {
String sql = "DELETE FROM books WHERE id=?";

try (Connection connection = ConnectionUtil.getConnections();
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
preparedStatement.setLong(1, id);
int affectedRows = preparedStatement.executeUpdate();
if (affectedRows == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import java.util.List;
import java.util.Optional;
import mate.academy.dao.BookDao;
import mate.academy.dao.BookDaoImpl;
import mate.academy.exeption.DataProcessingException;
import mate.academy.lib.Dao;
import mate.academy.lib.Injector;
import mate.academy.model.Book;
import mate.academy.service.BookService;

Expand Down

0 comments on commit f6d476c

Please sign in to comment.