Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:06:05+00:00 2026-06-05T12:06:05+00:00

I’m setting up a failover cluster on MySQL, in a master/slave architecture. I’m also

  • 0

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 connection, knowing that it is for Alfresco (which is using Ibatis).

Even I praticed MySQL many times, I don’t know very well internals mechanisms of execution in MySQL Server.

So far, I’m using this query to test my SQL connection (like in this thread : Database Fail Over in Jboss Data sources)

SELECT 1;

Here the full datasource.

<?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>

I have multiple question that I’m not able to answer by myself:

  • Won’t this simple query be cached by Ibatis (or any kind or ORM) ? This would mean that it could return me false results.
  • Won’t that query be too simple ? Is it really trying to execute internal mechanisms that would be representative of server health ? Or will it test only connection ?
  • Is it really a reliable test ?
  • Is there any other kind of test (already integrated with Connector/J for instance) ?
  • Performance is also important for me, so is SELECT 1 is a good compromise between health check and performance

Don’t hesitate to point me out some links (inside Stackoverflow or not). If this question have bean already answered (it seems not, as far as I searched), I will obviously delete this thread.

I would much appreciate returns of exeperience of mysql developpers or administrators. I’m looking for the best way to do it.

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:06:06+00:00Added an answer on June 5, 2026 at 12:06 pm

    Quoting this link: Ping MySQL Server Using JDBC

    you have to:

    The MySQL JDBC driver (Connector/J) provides a ping mechanism.

    If you do a SQL query prepended with /* ping */ such as:

    “/* ping */ SELECT 1” This will actually cause the driver send a ping
    to the server and return a fake, light-weight, result set.

    (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.).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.