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

Jbdc #384

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

Jbdc #384

wants to merge 6 commits into from

Conversation

ChabVlad
Copy link

No description provided.

import java.math.BigDecimal;

public class Book {
private long id;

Choose a reason for hiding this comment

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

Suggested change
private long id;
private Long id;

Long id = resultSet.getObject("id", Long.class);
String title = resultSet.getString("title");
BigDecimal price = resultSet.getBigDecimal("price");
Book selectedBook = new Book();

Choose a reason for hiding this comment

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

Suggested change
Book selectedBook = new Book();
Book book = new Book();

CREATE DATABASE 'books_db';

CREATE TABLE 'books' (
'id' BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT,

Choose a reason for hiding this comment

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

Suggested change
'id' BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT,
'id' BIGINT PRIMARY KEY AUTO_INCREMENT,

MySQL automatically add not null and unique when you declare id as PK

public class Main {
public static void main(String[] args) {
private static Injector injector = Injector.getInstance("mate.academy");

Choose a reason for hiding this comment

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

Suggested change
private static Injector injector = Injector.getInstance("mate.academy");
private static final Injector injector = Injector.getInstance("mate.academy");

return Optional.of(book);
}
} catch (SQLException e) {
throw new DataProcessingException("Can ot find book by id" + id, e);

Choose a reason for hiding this comment

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

Suggested change
throw new DataProcessingException("Can ot find book by id" + id, e);
throw new DataProcessingException("Can not find book by id" + id, e);

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