-
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
Solved task jv-jdbc-intro: #351
base: main
Are you sure you want to change the base?
Conversation
ASelivonchyk
commented
May 14, 2024
- implemented BookDao class with CRUD operations to retrieve needed data from DB;
- created util class - ConnectionUtil to establish connection with DB;
- added DbException and DataProcessingException as custom exceptions;
- all application constants moved for separate Constants class;
- used app.properties file for common variables;
- edited init_db.sql for creating DB schema and table;
- in pom.xml added necessary dependency;
- implemented BookDao class with CRUD operations to retrieve needed data from DB; - created util class - ConnectionUtil to establish connection with DB; - added DbException and DataProcessingException as custom exceptions; - all application constants moved for separate Constants class; - used app.properties file for common variables; - edited init_db.sql for creating DB schema and table; - in pom.xml added necessary dependency;
.prepareStatement(SAVE_BOOK_QUERY, Statement.RETURN_GENERATED_KEYS)) { | ||
createBookStatement.setString(1, book.getTitle()); | ||
createBookStatement.setBigDecimal(2, book.getPrice()); | ||
createBookStatement.executeUpdate(); |
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.
Do you need to check affected rows?
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.
I don't think so.
package mate.academy.exception; | ||
|
||
public class DataProcessingException extends RuntimeException { | ||
|
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.
import mate.academy.exception.DbException; | ||
|
||
public class ConnectionUtil { | ||
private static final Properties dbProperties = new Properties(); |
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 final Properties dbProperties = new Properties(); | |
private static final Properties DB_PROPERTIES = new Properties(); |
constant naming convention
package mate.academy.exception; | ||
|
||
public class DbException extends RuntimeException { | ||
|
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.