5

关于 mysql-connector- Java 在执行 insert 跟 update 之前都要去读取一下数据库是否...

 3 years ago
source link: https://www.v2ex.com/t/786344
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Java

关于 mysql-connector- Java 在执行 insert 跟 update 之前都要去读取一下数据库是否 read only 这合理吗?

  0576coder · 10 小时 3 分钟前 · 280 次点击

mysql-connector-java 8.0.x

问题 执行 insert 或者 update 的时候都回去判断数据库是否只读,手动查看源码在这里

b04ab9feab21bfca.png

这里就是判断了数据库版本版本 然后根据版本不同去

select @@session.tx_read_only

select @@session.transaction_read_only

虽然这样做很严谨 但是我感觉读写分离之类的应该在数据库中间件或者手动指定库来区别,为什么要多次一举这么设计


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK