What's the best practice to ensure atomic read of a database table using JDBC?

前端 未结 6 1388
情深已故
情深已故 2021-02-19 06:26

I have an java application reading from a database table for jobs to process, and I may have multiple instances of this application running on different servers as each job is i

6条回答
  •  别跟我提以往
    2021-02-19 07:18

    Use ResultSet that has CONCUR_READ_ONLY and TYPE_FORWARD_ONLY. If your database jdbc driver supports it, it will only return atomic read of your select time.

    According to this documentation, (Table Summary of Visibility of Internal and External Changes)

    forward-only cursor will only show your read time results. CONCUR_READ_ONLY will prevent your internal updates.

提交回复
热议问题