提交 67ea49f6 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Server mode: concurrently using the same connection could throw an exception…

Server mode: concurrently using the same connection could throw an exception Connection is broken: unexpected status
上级 b924508d
......@@ -21,6 +21,9 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Server mode: concurrently using the same connection could throw an exception
"Connection is broken: unexpected status".
</li>
<li>Performance improvement for metadata queries that join against the COLUMNS metadata table.
</li>
<li>An ArrayIndexOutOfBoundsException was thrown in some cases
......
......@@ -242,7 +242,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
}
}
private void setAutoCommitSend(boolean autoCommit) {
private synchronized void setAutoCommitSend(boolean autoCommit) {
if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_8) {
for (int i = 0, count = 0; i < transferList.size(); i++) {
Transfer transfer = transferList.get(i);
......
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.jdbc;
import java.io.ByteArrayInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.h2.test.TestBase;
import org.h2.util.Task;
/**
* Test concurrent usage of the same connection.
*/
public class TestConcurrentConnectionUsage extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
@Override
public void test() throws SQLException {
testAutoCommit();
}
private void testAutoCommit() throws SQLException {
; config.networked = true;
deleteDb(getTestName());
final Connection conn = getConnection(getTestName());
final PreparedStatement p1 = conn.prepareStatement("select 1 from dual");
Task t = new Task() {
@Override
public void call() throws Exception {
while (!stop) {
p1.executeQuery();
conn.setAutoCommit(true);
conn.setAutoCommit(false);
}
}
}.execute();
PreparedStatement prep = conn.prepareStatement("select ? from dual");
for (int i = 0; i < 10; i++) {
prep.setBinaryStream(1, new ByteArrayInputStream(new byte[1024]));
prep.executeQuery();
}
t.get();
conn.close();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论