Spring Boot JDBCTemplate Optimistic Locking Example with MySQL and Java Multithreading
I show you how to perform optimistic locking with Java, SpringBoot and MySQL.
Pessimistic Locking VS Optimistic Locking
JDBCTemplate Optimistic Locking
NamedParameterJdbcTemplate Optimistic Locking
DataSourceTransactionManager
@Transactional annotation
I demonstrate the persistence lost update problem by creating a demo spring boot application containing a REST API and a JDBC template persistence layer.
Optimistic database locking can be achieved with many techniques, some popular methods are with a version column, or a modified integer column.
As a relational database will guarantee the ACID properties, we will ensure that each database write is performed within a transaction (Read committed transaction propagation if fine).
Each transaction will add a where clause to the sql, the where condition will ensure that the row's current value has not changed. And therefore guaranteed that the row has not been updated between the read/write. (As long as all writes follow the same transaction / code path).
Enjoy the demo!
Lost update problem and solve
Java Transaction Propagation Levels
Database connection Transaction Isolation Levels
Concurrency Control
Java
SpringBoot
SpringFramework
RESTful Webservice
Tomcat HTTP Request Thread breakpoint analysis
HTTP concurrency example
properties file MySQL Datasource JDBCTemplate autoconfiguration
Subscribe for more great tech content!
Enjoy!
Philip
Video Location: Slieve League Cliffs - Ireland, Co Donegal.
https://en.wikipedia.org/wiki/Slieve_League
Microsoft Concurrency Effects: https://technet.microsoft.com/en-us/library/ms190805(v=sql.105).aspx
Optimistic concurrency control: https://en.wikipedia.org/wiki/Optimistic_concurrency_control
Transaction Isolation Levels: https://en.wikipedia.org/wiki/Isolation_(database_systems)
Spring Framework JDBC: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jdbc.html
JdbcTemplate: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html
Spring Transaction Management: http://docs.spring.io/autorepo/docs/spring/current/spring-framework-reference/html/transaction.html
Spring Boot Working with SQL Databases: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html
Spring Boot Configure a Datasource: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Spring Boot JDBCTemplate Optimistic Locking Example with MySQL and Java Multithreading», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.