Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Hw 23 solution #382

wants to merge 9 commits into from

Conversation

ipantazi
Copy link

@ipantazi ipantazi commented Jul 8, 2024

Created init_db.sql, Classes: BookDaoImpl, ConnectionUtilImpl, DataProcessingException, Book, BookServiceImpl.
Created Interfaces: BookDao, ConnectionUtil, Entity, Table and BookService.
Edit Class Main.

…`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`.
Map.of("Java", new BigDecimal(300),
"Python", new BigDecimal(200),
"C++", new BigDecimal(100))
.forEach((key, value) -> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.forEach((key, value) -> {
.forEach((title, price) -> {

@Override
public List<Book> findAll() {
String sql = "SELECT * FROM books";
try (PreparedStatement prepareStatement = ConnectionUtilImpl.getConnection()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 = ?";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String sql = "UPDATE books SET title = ?, price = ?) WHERE id = ?";
String sql = "UPDATE books SET title = ?, price = ? WHERE id = ?";

@ipantazi ipantazi requested a review from MAMentorFX July 11, 2024 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants