1. 程式人生 > 資料庫 >java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed

java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed

今天更新資料時出現這個錯誤:

java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed

原因是:我在service層設定了只讀。@Transactional(readOnly = true)

而更新的方法沒有把可讀設定為FALSE。解決辦法是在方法上加上readOnly=FALSE

註解如下:    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)