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

Each session threw an invisible exception when garbage collected.

上级 b51cf46d
...@@ -18,7 +18,9 @@ Change Log ...@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>New meta data column INFORMATION_SCHEMA.TABLES.LAST_MODIFICATION to get <ul><li>Each session threw an invisible exception when garbage collected.
</li><li>Foreign key constraints referring to a quoted column did not work.
</li><li>New meta data column INFORMATION_SCHEMA.TABLES.LAST_MODIFICATION to get
the table modification counter. the table modification counter.
</li><li>Shell: line comments didn't work correctly. </li><li>Shell: line comments didn't work correctly.
</li><li>H2 Console: Columns are now listed for up to 500 tables instead of 100. </li><li>H2 Console: Columns are now listed for up to 500 tables instead of 100.
......
...@@ -42,9 +42,9 @@ import org.h2.value.ValueLong; ...@@ -42,9 +42,9 @@ import org.h2.value.ValueLong;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
/** /**
* A session represents a database connection. When using the server mode, this * A session represents an embedded database connection. When using the server
* object resides on the server side and communicates with a RemoteSession on * mode, this object resides on the server side and communicates with a
* the client side. * SessionRemote object on the client side.
*/ */
public class Session implements SessionInterface { public class Session implements SessionInterface {
...@@ -92,10 +92,6 @@ public class Session implements SessionInterface { ...@@ -92,10 +92,6 @@ public class Session implements SessionInterface {
private Table waitForLock; private Table waitForLock;
private int modificationId; private int modificationId;
public Session() {
// nothing to do
}
Session(Database database, User user, int id) { Session(Database database, User user, int id) {
this.database = database; this.database = database;
this.undoLog = new UndoLog(this); this.undoLog = new UndoLog(this);
...@@ -305,10 +301,6 @@ public class Session implements SessionInterface { ...@@ -305,10 +301,6 @@ public class Session implements SessionInterface {
this.lockTimeout = lockTimeout; this.lockTimeout = lockTimeout;
} }
public SessionInterface createSession(ConnectionInfo ci) throws SQLException {
return Engine.getInstance().getSession(ci);
}
public CommandInterface prepareCommand(String sql, int fetchSize) throws SQLException { public CommandInterface prepareCommand(String sql, int fetchSize) throws SQLException {
return prepareLocal(sql); return prepareLocal(sql);
} }
......
/*
* Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.engine;
import java.sql.SQLException;
/**
* A class that implements this interface can create new database sessions.
*/
public interface SessionFactory {
/**
* Create a new session.
*
* @param ci the connection parameters
* @return the new session
*/
SessionInterface createSession(ConnectionInfo ci) throws SQLException;
}
/*
* Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.engine;
import java.sql.SQLException;
/**
* A factory for embedded database sessions.
*/
public class SessionFactoryEmbedded implements SessionFactory {
public SessionInterface createSession(ConnectionInfo ci) throws SQLException {
return Engine.getInstance().getSession(ci);
}
}
...@@ -45,14 +45,6 @@ public interface SessionInterface { ...@@ -45,14 +45,6 @@ public interface SessionInterface {
*/ */
boolean isClosed(); boolean isClosed();
/**
* Open a new session.
*
* @param ci the connection parameters
* @return the new session
*/
SessionInterface createSession(ConnectionInfo ci) throws SQLException;
/** /**
* Get the number of disk operations before power failure is simulated. * Get the number of disk operations before power failure is simulated.
* This is used for testing. If not set, 0 is returned * This is used for testing. If not set, 0 is returned
......
...@@ -41,7 +41,7 @@ import org.h2.value.ValueString; ...@@ -41,7 +41,7 @@ import org.h2.value.ValueString;
* The client side part of a session when using the server mode. This object * The client side part of a session when using the server mode. This object
* communicates with a Session on the server side. * communicates with a Session on the server side.
*/ */
public class SessionRemote implements SessionInterface, DataHandler { public class SessionRemote implements SessionInterface, SessionFactory, DataHandler {
public static final int SESSION_PREPARE = 0; public static final int SESSION_PREPARE = 0;
public static final int SESSION_CLOSE = 1; public static final int SESSION_CLOSE = 1;
...@@ -244,11 +244,11 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -244,11 +244,11 @@ public class SessionRemote implements SessionInterface, DataHandler {
backup = (ConnectionInfo) ci.clone(); backup = (ConnectionInfo) ci.clone();
connectionInfo = (ConnectionInfo) ci.clone(); connectionInfo = (ConnectionInfo) ci.clone();
} }
SessionInterface si = (SessionInterface) ClassUtils.loadSystemClass("org.h2.engine.Session").newInstance(); SessionFactory sf = (SessionFactory) ClassUtils.loadSystemClass("org.h2.engine.SessionFactoryEmbedded").newInstance();
if (openNew) { if (openNew) {
ci.setProperty("OPEN_NEW", "true"); ci.setProperty("OPEN_NEW", "true");
} }
return si.createSession(ci); return sf.createSession(ci);
} catch (SQLException e) { } catch (SQLException e) {
int errorCode = e.getErrorCode(); int errorCode = e.getErrorCode();
if (errorCode == ErrorCode.DATABASE_ALREADY_OPEN_1) { if (errorCode == ErrorCode.DATABASE_ALREADY_OPEN_1) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论