-
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
Jbdc #384
base: main
Are you sure you want to change the base?
Jbdc #384
Conversation
import java.math.BigDecimal; | ||
|
||
public class Book { | ||
private long 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.
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(); |
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.
Book selectedBook = new Book(); | |
Book book = new Book(); |
src/main/resources/init_db.sql
Outdated
CREATE DATABASE 'books_db'; | ||
|
||
CREATE TABLE 'books' ( | ||
'id' BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, |
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.
'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
src/main/java/mate/academy/Main.java
Outdated
public class Main { | ||
public static void main(String[] args) { | ||
private static Injector injector = Injector.getInstance("mate.academy"); |
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.
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); |
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.
throw new DataProcessingException("Can ot find book by id" + id, e); | |
throw new DataProcessingException("Can not find book by id" + id, e); |
No description provided.