Oracle 5.0 Reference Manual page 2075

Table of Contents

Advertisement

Any other parameters are treated as host-specific properties that follow the conventions of the JDBC
URL properties. This now allows per-host overrides of any configuration property for multi-host
connections (that is, when using failover, load balancing, or replication). Limit the overrides to user,
password, network timeouts and statement and metadata cache sizes; the results of other per-host
overrides are not defined.
Initial Database for Connection
If the database is not specified, the connection is made with no default database. In this case, either
call the
setCatalog()
database name (that is,
your SQL. Opening a connection without specifying the database to use is generally only useful when
building tools that work with multiple databases, such as GUI database managers.
Failover Support
MySQL Connector/J has failover support. This enables the driver to fail over to any number of
slave hosts and still perform read-only queries. Failover only happens when the connection is in
an
autoCommit(true)
progress. Most application servers and connection pools set
transaction/connection use.
The failover functionality has the following behavior:
• If the URL property
and failback occurs when the driver determines that the first host has become available again.
• If the URL property
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
have been issued).
In either case, whenever you are connected to a "failed-over" server, the connection is set to read-only
state, so queries that attempt to modify data will throw exceptions (the query will never be processed
by the MySQL server).
Setting Configuration Properties
Configuration properties define how Connector/J will make a connection to a MySQL server. Unless
otherwise noted, properties can be set for a
Configuration properties can be set in one of the following ways:
• Using the
preferred method when using implementations of java.sql.DataSource):
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
• As a key/value pair in the
DriverManager.getConnection()
• As a JDBC URL parameter in the URL given to java.sql.DriverManager.getConnection(),
java.sql.Driver.connect()
setURL()
Connector/J (JDBC) Reference
method on the Connection instance, or fully specify table names using the
SELECT dbname.tablename.colname FROM
Note
Always use the
database in JDBC applications, rather than the
state, because failover cannot happen reliably when a
autoReconnect
autoReconnect
methods on MySQL implementations of
set*()
java.util.Properties
method.
Connection.setCatalog()
is false: Failover only happens at connection initialization,
is true: Failover happens when the driver determines that
DataSource
instance passed to
or
Driver.connect()
or the MySQL implementations of the
2055
dbname.tablename...) in
method to specify the desired
USE database
transaction
to
autoCommit
true
queriesBeforeRetryMaster
object or for a
Connection
java.sql.DataSource
javax.sql.DataSource
statement.
is in
at the end of every
queries
object.
(which is the

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents