-
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
Hw 23 solution #382
base: main
Are you sure you want to change the base?
Hw 23 solution #382
Conversation
…`DataProcessingException`, `Book`, `BookServiceImpl`. Created Interfaces: `BookDao`, `ConnectionUtil`, `Entity`, `id`, `Table` and `BookService`. Edit Class `Main`.
…`DataProcessingException`, `Book`, `BookServiceImpl`. Created Interfaces: `BookDao`, `ConnectionUtil`, `Entity`, `Table` and `BookService`. Edit Class `Main`.
…`DataProcessingException`, `Book`, `BookServiceImpl`. Created Interfaces: `BookDao`, `ConnectionUtil`, `Entity`, `Table` and `BookService`. Edit Class `Main`.
src/main/java/mate/academy/Main.java
Outdated
Map.of("Java", new BigDecimal(300), | ||
"Python", new BigDecimal(200), | ||
"C++", new BigDecimal(100)) | ||
.forEach((key, value) -> { |
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.
.forEach((key, value) -> { | |
.forEach((title, price) -> { |
@Override | ||
public List<Book> findAll() { | ||
String sql = "SELECT * FROM books"; | ||
try (PreparedStatement prepareStatement = ConnectionUtilImpl.getConnection() |
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.
try (PreparedStatement prepareStatement = ConnectionUtilImpl.getConnection() | |
try (Statement prepareStatement = ConnectionUtilImpl.getConnection() |
It's more efficient to use Statement, if there are no ?-parameters
|
||
@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.
String sql = "UPDATE books SET title = ?, price = ?) WHERE id = ?"; | |
String sql = "UPDATE books SET title = ?, price = ? WHERE id = ?"; |
Created
init_db.sql
, Classes:BookDaoImpl
,ConnectionUtilImpl
,DataProcessingException
,Book
,BookServiceImpl
.Created Interfaces:
BookDao
,ConnectionUtil
,Entity
,Table
andBookService
.Edit Class
Main
.