Top Description Fields Constructors Methods
org.h2.table

public Class TableLinkConnection

extends Object
Class Inheritance
Imports
java.sql.Connection, .SQLException, java.util.HashMap, .Objects, org.h2.message.DbException, org.h2.util.JdbcUtils

A connection for a linked table. The same connection may be used for multiple tables, that means a connection may be shared.

Field Summary

Modifier and TypeField and Description
private boolean
private Connection
conn

The database connection.

private final String
driver

The connection information.

private final HashMap<TableLinkConnection, TableLinkConnection>
map

The map where the link is kept.

private final String
password

The connection information.

private final String
url

The connection information.

private int
useCounter

How many times the connection is used.

private final String
user

The connection information.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv void
close(boolean
if the connection needs to be closed even if it is still used elsewhere (for example, because the connection is broken)
force
)

Closes the connection if this is the last link to it.

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public boolean

Returns:

true if autocommit is on
getAutocommit
()

The autocommit mode

pack-priv Connection

Returns:

the connection
getConnection
()

Get the connection.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public static TableLinkConnection

Returns:

a connection
open
(HashMap<TableLinkConnection, TableLinkConnection>
the map where the connection should be stored (if shared connections are enabled).
map
,
String
the JDBC driver class name
driver
,
String
the database URL
url
,
String
the user name
user
,
String
the password
password
,
boolean
if connections should be shared
shareLinkedConnections
)

Open a new connection.

private void
open()

public void
setAutoCommit(boolean
to set
mode
)

Specify if the autocommit mode is activated or not

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

autocommitback to summary
private boolean autocommit
connback to summary
private Connection conn

The database connection.

driverback to summary
private final String driver

The connection information.

mapback to summary
private final HashMap<TableLinkConnection, TableLinkConnection> map

The map where the link is kept.

passwordback to summary
private final String password

The connection information.

urlback to summary
private final String url

The connection information.

useCounterback to summary
private int useCounter

How many times the connection is used.

userback to summary
private final String user

The connection information.

Constructor Detail

TableLinkConnectionback to summary
private TableLinkConnection(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password)

Method Detail

closeback to summary
pack-priv void close(boolean force)

Closes the connection if this is the last link to it.

Parameters
force:boolean

if the connection needs to be closed even if it is still used elsewhere (for example, because the connection is broken)

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAutocommitback to summary
public boolean getAutocommit()

The autocommit mode

Returns:boolean

true if autocommit is on

getConnectionback to summary
pack-priv Connection getConnection()

Get the connection. This method and methods on the statement must be synchronized on this object.

Returns:Connection

the connection

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
openback to summary
public static TableLinkConnection open(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password, boolean shareLinkedConnections)

Open a new connection.

Parameters
map:HashMap<TableLinkConnection, TableLinkConnection>

the map where the connection should be stored (if shared connections are enabled).

driver:String

the JDBC driver class name

url:String

the database URL

user:String

the user name

password:String

the password

shareLinkedConnections:boolean

if connections should be shared

Returns:TableLinkConnection

a connection

openback to summary
private void open()
setAutoCommitback to summary
public void setAutoCommit(boolean mode)

Specify if the autocommit mode is activated or not

Parameters
mode:boolean

to set