MySQL connection validity test in datasource : SELECT 1 or something better?

前端 未结 2 454
庸人自扰
庸人自扰 2021-01-04 10:20

I\'m setting up a failover cluster on MySQL, in a master/slave architecture. I\'m also configuring my JBoss Datasource, and I\'m looking for the better way to test my connec

2条回答
  •  孤城傲影
    2021-01-04 10:27

    The query we use at work to check the connection to a MySQL server is SHOW databases; which is nice and simple as it doesn't need you to have selected a particular database. I'd say it's pretty reliable and a query like that is pretty efficient.

提交回复
热议问题