Data source & Transaction

0.0(0)
studied byStudied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/6

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:45 AM on 2/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

7 Terms

1
New cards

What is a datasource

The component that manages database connections. Usually it creates a connection pool, and serves connections to the server.

2
New cards

How to initialize sql schema and init data in spring boot

Create schema.sql and data.sql files inside resources.

3
New cards

What is JDBC template

Convenient abstraction over JDBC. More convenient than working with Stamtements and PreparedStatements, but it still uses Native sql queries.

4
New cards

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.

5
New cards

How to use datasource with spring boot

  1. add dependencies: jdbc, driver

  2. create config in config file: url, username, password

  3. Create optional HikariCP datasource bean.

6
New cards

What is a transaction?

Groups commands together and ensures that they all execute or none of them do.

7
New cards

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