提交 ea85b1f7 authored 作者: Thomas Mueller's avatar Thomas Mueller

Linked tables: the automatic connection sharing didn't work.

上级 ccb9957a
......@@ -62,7 +62,7 @@ public class TableLinkConnection {
*/
public static TableLinkConnection open(HashMap map, String driver, String url, String user, String password) throws SQLException {
TableLinkConnection t = new TableLinkConnection(map, driver, url, user, password);
if (SysProperties.SHARE_LINKED_CONNECTIONS) {
if (!SysProperties.SHARE_LINKED_CONNECTIONS) {
t.open();
return t;
}
......
......@@ -33,6 +33,7 @@ public class TestLinkedTable extends TestBase {
public void test() throws SQLException {
// testLinkAutoAdd();
testSharedConnection();
testMultipleSchemas();
testReadOnlyLinkedTable();
testLinkOtherSchema();
......@@ -63,6 +64,24 @@ public class TestLinkedTable extends TestBase {
// cb.close();
// }
private void testSharedConnection() throws SQLException {
org.h2.Driver.load();
deleteDb("linkedTable");
String url = getURL("linkedTable", true);
String user = getUser();
String password = getPassword();
Connection ca = getConnection(url, user, password);
Statement sa = ca.createStatement();
sa.execute("CREATE TABLE TEST(ID INT)");
ca.close();
Connection cb = DriverManager.getConnection("jdbc:h2:mem:two", "sa", "sa");
Statement sb = cb.createStatement();
sb.execute("CREATE LINKED TABLE T1(NULL, '" + url + ";OPEN_NEW=TRUE', '"+user+"', '"+password+"', 'TEST')");
sb.execute("CREATE LINKED TABLE T2(NULL, '" + url + ";OPEN_NEW=TRUE', '"+user+"', '"+password+"', 'TEST')");
sb.execute("DROP ALL OBJECTS");
cb.close();
}
private void testMultipleSchemas() throws SQLException {
org.h2.Driver.load();
Connection ca = DriverManager.getConnection("jdbc:h2:mem:one", "sa", "sa");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论