使用JDBC Ping MySQL服务器 [英] Ping MySQL Server Using JDBC
问题描述
这看起来相当简单(不适合我)...
This seems rather simple (not for me)...
如何使用JDBC ping mysql服务器?我已成功使用JDBC和MySQL的select和insert查询,但如何ping ???
How does one ping a mysql server using the JDBC? i have successfully used select and insert queries with JDBC and MySQL, but how to ping???
TIA
推荐答案
MySQL JDBC驱动程序(Connector / J)提供了ping机制。
The MySQL JDBC driver (Connector/J) provides a ping mechanism.
如果您使用 / * ping * /
进行SQL查询,例如:
If you do a SQL query prepended with /* ping */
such as:
"/* ping */ SELECT 1"
这实际上会导致驱动程序向服务器发送ping并返回假的,轻量级的结果集。
This will actually cause the driver send a ping to the server and return a fake, light-weight, result set.
(你可以找到这个深埋在 Connector / J中文档;在该页面上搜索ping。仔细阅读:这种机制对所使用的语法非常敏感。与大多数SQL不同,ping标记的解析发生在客户端JDBC驱动程序本身。)。
(You can find this buried fairly deep in the Connector/J documentation; search for "ping" on that page. Read it carefully: this mechanism is very sensitive to the syntax used. Unlike most SQL, the "parsing" of the "ping" marker happens in the client-side JDBC driver itself.).
这篇关于使用JDBC Ping MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!