Jea*_*evy 11 mysql orm database-connection datasource jdbc
我正在MySQL上建立一个主/从体系结构的故障转移集群.我也正在配置我的JBoss数据源,我正在寻找更好的方法来测试我的连接,因为它知道它适用于Alfresco(使用Ibatis).
即使我多次尝试MySQL,我也不太清楚MySQL服务器内部的执行机制.
到目前为止,我正在使用此查询来测试我的SQL连接(就像在这个线程中:Jboss数据源中的数据库故障转移)
SELECT 1;
Run Code Online (Sandbox Code Playgroud)
这里是完整的数据源.
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>alfresco-datasource</jndi-name>
<connection-url>
jdbc:mysql://10.1.2.13,10.1.2.14:3306/alfresco
</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>alfresco</user-name>
<password>alfresco</password>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
</exception-sorter-class-name>
<connection-property name="readOnly">false</connection-property>
<failOverReadOnly>false</failOverReadOnly>
<!-- Automatic reconnecion - desactivated to preserve transactions -->
<!-- http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html :
Failover happens when the driver determines that the connection has failed (checked before every query), and falls back to the first host when it determines that the host has become available again (after queriesBeforeRetryMaster queries have been issued). -->
<!--<autoReconnect>true</autoReconnect>-->
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<valid-connection-checker-class-name>
org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker
</valid-connection-checker-class-name>
<!-- If you're using Connector/J 3.1.8 or newer, you can use our implementation
of these to increase the robustness "mysql-ds.xml" 64L, 3683C of the connection
pool. -->
<exception-sorter-class-name>
com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter
</exception-sorter-class-name>
<valid-connection-checker-class-name>
com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker
</valid-connection-checker-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Run Code Online (Sandbox Code Playgroud)
我有多个问题,我无法自己回答:
不要犹豫,指出一些链接(在Stackoverflow内部或不是).如果这个问题已经回答了bean(似乎没有,就我搜索而言),我显然会删除这个帖子.
我非常感谢mysql开发人员或管理员的经验回报.我正在寻找最好的方法.
谢谢你的帮助.
Seb*_*bas 19
引用此链接:使用JDBC Ping MySQL服务器
你必须:
MySQL JDBC驱动程序(Connector/J)提供了ping机制.
如果您使用/*ping*/进行SQL查询,例如:
"/*ping*/SELECT 1"这实际上会导致驱动程序向服务器发送ping并返回假的,轻量级的结果集.
(您可以在Connector/J文档中找到相当深入的内容;在该页面上搜索"ping".请仔细阅读:此机制对所使用的语法非常敏感.与大多数SQL不同,"解析""ping" "标记发生在客户端JDBC驱动程序本身.).
归档时间: |
|
查看次数: |
10616 次 |
最近记录: |