Package org.h2.table
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 boolean
private Connection
The database connection.private final String
The connection information.private final HashMap
<TableLinkConnection, TableLinkConnection> The map where the link is kept.private final String
The connection information.private final String
The connection information.private int
How many times the connection is used.private final String
The connection information. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
TableLinkConnection
(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password) -
Method Summary
Modifier and TypeMethodDescription(package private) void
close
(boolean force) Closes the connection if this is the last link to it.boolean
boolean
The autocommit mode(package private) Connection
Get the connection.int
hashCode()
private void
open()
static TableLinkConnection
open
(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password, boolean shareLinkedConnections) Open a new connection.void
setAutoCommit
(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
public int 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
-