Class TableLinkConnection
java.lang.Object
org.h2.table.TableLinkConnection
A connection for a linked table. The same connection may be used for multiple
tables, that means a connection may be shared.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate ConnectionThe database connection.private final StringThe connection information.private final HashMap<TableLinkConnection, TableLinkConnection> The map where the link is kept.private final StringThe connection information.private final StringThe connection information.private intHow many times the connection is used.private final StringThe connection information. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTableLinkConnection(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password) -
Method Summary
Modifier and TypeMethodDescription(package private) voidclose(boolean force) Closes the connection if this is the last link to it.booleanbooleanThe autocommit mode(package private) ConnectionGet the connection.inthashCode()private voidopen()static TableLinkConnectionopen(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password, boolean shareLinkedConnections) Open a new connection.voidsetAutoCommit(boolean mode) Specify if the autocommit mode is activated or not
-
Field Details
-
map
The map where the link is kept. -
driver
The connection information. -
url
The connection information. -
user
The connection information. -
password
The connection information. -
conn
The database connection. -
useCounter
private int useCounterHow many times the connection is used. -
autocommit
private boolean autocommit
-
-
Constructor Details
-
TableLinkConnection
private TableLinkConnection(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password)
-
-
Method Details
-
open
public static TableLinkConnection open(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password, boolean shareLinkedConnections) Open a new connection.- Parameters:
map- the map where the connection should be stored (if shared connections are enabled).driver- the JDBC driver class nameurl- the database URLuser- the user namepassword- the passwordshareLinkedConnections- if connections should be shared- Returns:
- a connection
-
open
private void open() -
hashCode
-
equals
-
getConnection
Connection getConnection()Get the connection. This method and methods on the statement must be synchronized on this object.- Returns:
- the connection
-
close
void close(boolean force) Closes the connection if this is the last link to it.- Parameters:
force- if the connection needs to be closed even if it is still used elsewhere (for example, because the connection is broken)
-
setAutoCommit
public void setAutoCommit(boolean mode) Specify if the autocommit mode is activated or not- Parameters:
mode- to set
-
getAutocommit
public boolean getAutocommit()The autocommit mode- Returns:
- true if autocommit is on
-