-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lopez David E-r9374c wrote:

> Dudes & Dudetts
>
> filter: mysql, select, sql
> mysql version: 3.23.49
> jdbc version: 2.0.14
> development os: win2k
> production os: solaris
>
> Problem:
> --------
> During a reboot of mysqld, the perl connections survived
> and the jdbc connections did not. My definition of survived is
> that the connections waited until mysqld rebooted and automatically
> reconnected.
>
> Discussion
> ----------
>
> None of the jdbc connections survived. Back to the books I went.
> I did not have the properties that control this behavior:
>   autoReconnect, maxReconnects, initialTimeout
>
> I changed my url + db + properties to:
> jdbc:mysql://localhost/db1?user=david&passward=secret&\
> autoReconnect=true&maxReconnects=5&initialTimeout=10
>
> (The trailing backslash is simply for ledgability - not in code)
>
> I believe this translates to:
>   If connection is lost, keep trying 5 times and wait 10 seconds
>   between retrys.

Not exactly, it means it will first wait 10, then 100 , then 10000, then
10000000 then 100000000000000 seconds (it's an exponential backoff).

In any case, 'autoReconnect' is a crutch (I don't recommend that you use
it) that should not be relied upon. Your application should be able to
recover from exceptions itself, that's just good coding practice.
Relying on the JDBC driver to do it can be dangerous...Only your
application _really_ knows when it is appropriate to retry a transaction.

AutoReconnect also only keeps an established connection re-connected. It
doesn't retry failed attempts to connect (it wasn't designed to).

Any communication-level error in JDBC for MySQL has a SQLSTATE of
'08S01', so you can check for that, and handle it appropriately in your
application.

        -Mark
- --
For technical support contracts, visit https://order.mysql.com/?ref=mmma

    __  ___     ___ ____  __
   /  |/  /_ __/ __/ __ \/ /  Mark Matthews <[EMAIL PROTECTED]>
  / /|_/ / // /\ \/ /_/ / /__ MySQL AB, SW Dev. Manager - J2EE/Windows
 /_/  /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
        <___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+35YktvXNTca6JD8RApiUAKDErofASLK5G0cDo4pjFIy9o1LxcQCeN6dr
8QUr2I35s7Sgf1/p+vmMreQ=
=YyJI
-----END PGP SIGNATURE-----


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to