mirror of https://github.com/apache/openjpa.git
OPENJPA-966: Support MySQL Replication Driver
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@751487 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f1d4abda25
commit
23b0b87674
|
@ -641,6 +641,11 @@ public class JDBCStoreManager
|
|||
}
|
||||
|
||||
public Collection flush(Collection sms) {
|
||||
try {
|
||||
if (_conn != null && _conn.getInnermostDelegate().isReadOnly())
|
||||
_conn.setReadOnly(false);
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
return _conf.getUpdateManagerInstance().flush(sms, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -146,6 +146,13 @@ public class MySQLDictionary
|
|||
}
|
||||
}
|
||||
|
||||
public Connection decorate(Connection conn) throws SQLException {
|
||||
String driver = conf.getConnectionDriverName();
|
||||
if ("com.mysql.jdbc.ReplicationDriver".equals(driver))
|
||||
conn.setReadOnly(true);
|
||||
return conn;
|
||||
}
|
||||
|
||||
private static int[] getMajorMinorVersions(String versionStr)
|
||||
throws IllegalArgumentException {
|
||||
int beginIndex = 0;
|
||||
|
|
|
@ -3215,9 +3215,40 @@ action is used. (See <xref linkend="ref_guide_schema_schematool"/> for
|
|||
more info about <literal>deleteTableContents</literal>.) Defaults to
|
||||
<literal>false</literal>, since the statement may fail if using InnoDB
|
||||
tables and delete constraints.
|
||||
</para>
|
||||
</para>
|
||||
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Starting with Connector/J 3.1.7, MySQL supports a variant of the driver
|
||||
<literal>com.mysql.jdbc.ReplicationDriver</literal> that automatically sends
|
||||
queries to a read/write master, or a failover or round-robin load balanced set
|
||||
of slaves based on the state of read-only status of the connection.
|
||||
See <ulink url="http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-replication-connection.html">
|
||||
MySQL Reference</ulink> for more details.
|
||||
</para>
|
||||
<para>
|
||||
This replication feature can be used transparently with OpenJPA application by
|
||||
following configuration:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>openjpa.ConnectionDriverName: com.mysql.jdbc.ReplicationDriver</literal>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>openjpa.ConnectionFactoryProperties: autoReconnect=true,roundRobinLoadBalance=true</literal>
|
||||
</para>
|
||||
<para>
|
||||
OpenJPA will use a read-only connection with replicated database configuration
|
||||
and will automatically switch the connection to a non-readonly mode if the
|
||||
transaction is writing to the database.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="ref_guide_dbsetup_dbsupport_oracle">
|
||||
<title>
|
||||
|
|
Loading…
Reference in New Issue