Package org.h2.table
Class TableLinkConnection
- java.lang.Object
-
- org.h2.table.TableLinkConnection
-
public class TableLinkConnection extends java.lang.Object
A connection for a linked table. The same connection may be used for multiple tables, that means a connection may be shared.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
autocommit
private java.sql.Connection
conn
The database connection.private java.lang.String
driver
The connection information.private java.util.HashMap<TableLinkConnection,TableLinkConnection>
map
The map where the link is kept.private java.lang.String
password
The connection information.private java.lang.String
url
The connection information.private int
useCounter
How many times the connection is used.private java.lang.String
user
The connection information.
-
Constructor Summary
Constructors Modifier Constructor Description private
TableLinkConnection(java.util.HashMap<TableLinkConnection,TableLinkConnection> map, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
close(boolean force)
Closes the connection if this is the last link to it.boolean
equals(java.lang.Object o)
boolean
getAutocommit()
The autocommit mode(package private) java.sql.Connection
getConnection()
Get the connection.int
hashCode()
private void
open()
static TableLinkConnection
open(java.util.HashMap<TableLinkConnection,TableLinkConnection> map, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password, boolean shareLinkedConnections)
Open a new connection.void
setAutoCommit(boolean mode)
Specify if the autocommit mode is activated or not
-
-
-
Field Detail
-
map
private final java.util.HashMap<TableLinkConnection,TableLinkConnection> map
The map where the link is kept.
-
driver
private final java.lang.String driver
The connection information.
-
url
private final java.lang.String url
The connection information.
-
user
private final java.lang.String user
The connection information.
-
password
private final java.lang.String password
The connection information.
-
conn
private java.sql.Connection conn
The database connection.
-
useCounter
private int useCounter
How many times the connection is used.
-
autocommit
private boolean autocommit
-
-
Constructor Detail
-
TableLinkConnection
private TableLinkConnection(java.util.HashMap<TableLinkConnection,TableLinkConnection> map, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
-
-
Method Detail
-
open
public static TableLinkConnection open(java.util.HashMap<TableLinkConnection,TableLinkConnection> map, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.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()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
getConnection
java.sql.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
-
-