提交 0453eaba authored 作者: Thomas Mueller's avatar Thomas Mueller

Documentation (Spring workaround).

上级 7f5f2067
......@@ -1250,6 +1250,7 @@ Please note that changing the time zone after the H2 driver is loaded is not sup
</p>
<h2 id="spring">Using Spring</h2>
<h3>Using the TCP Server</h3>
<p>
Use the following configuration to start and stop the H2 TCP server using the Spring Framework:
</p>
......@@ -1266,6 +1267,46 @@ Use the following configuration to start and stop the H2 TCP server using the Sp
The <code>destroy-method</code> will help prevent exceptions on hot-redeployment or when restarting the server.
</p>
<h3>Error Code Incompatibility</h3>
<p>
There is an incompatibility with the Spring JdbcTemplate and H2 version 1.3.154 and newer,
because of a change in the error code. This will cause the JdbcTemplate to not detect
a duplicate key condition, and so a <code>DataIntegrityViolationException</code> is thrown instead of
<code>DuplicateKeyException</code>.
See also <a href="https://jira.springsource.org/browse/SPR-8235">the issue SPR-8235</a>.
The workaround is to add the following XML file to the root of the classpath:
</p>
<pre>
&lt;beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
&gt;
&lt;import resource="classpath:org/springframework/jdbc/support/sql-error-codes.xml"/&gt;
&lt;bean id="H2" class="org.springframework.jdbc.support.SQLErrorCodes"&gt;
&lt;property name="badSqlGrammarCodes"&gt;
&lt;value&gt;
42000,42001,42101,42102,42111,42112,42121,42122,42132
&lt;/value&gt;
&lt;/property&gt;
&lt;property name="duplicateKeyCodes"&gt;
&lt;value&gt;23001,23505&lt;/value&gt;
&lt;/property&gt;
&lt;property name="dataIntegrityViolationCodes"&gt;
&lt;value&gt;22003,22012,22025,23000&lt;/value&gt;
&lt;/property&gt;
&lt;property name="dataAccessResourceFailureCodes"&gt;
&lt;value&gt;90046,90100,90117,90121,90126&lt;/value&gt;
&lt;/property&gt;
&lt;property name="cannotAcquireLockCodes"&gt;
&lt;value&gt;50200&lt;/value&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;/beans&gt;
</pre>
<h2 id="jmx">Java Management Extension (JMX)</h2>
<p>
Management over JMX is supported, but not enabled by default.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论