1/6
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is a datasource
The component that manages database connections. Usually it creates a connection pool, and serves connections to the server.
How to initialize sql schema and init data in spring boot
Create schema.sql and data.sql files inside resources.
What is JDBC template
Convenient abstraction over JDBC. More convenient than working with Stamtements and PreparedStatements, but it still uses Native sql queries.
JDBC template methods and what is RowMapper
methods:
update() - uses it for insert, update, delete SQL commands
query() - select
rowmapper is used with select - maps the resultset to the result objects.
How to use datasource with spring boot
add dependencies: jdbc, driver
create config in config file: url, username, password
Create optional HikariCP datasource bean.
What is a transaction?
Groups commands together and ensures that they all execute or none of them do.
How to make a transaction in spring boot, and how does it work?
annotate method with @Transactional
rollback happens on thrown RuntimeException → if you catch it, it won’t roll back!! U can customize this for Exception class