Top Description Fields Constructors Methods
org.h2.jdbc

public Class JdbcConnection

extends TraceObject
implements Connection, CastDataProvider
Class Inheritance
All Implemented Interfaces
org.h2.engine.CastDataProvider, java.sql.Connection, java.lang.AutoCloseable, java.sql.Wrapper
Known Direct Subclasses
org.h2.jdbcx.JdbcXAConnection.PooledJdbcConnection
Imports
java.io.InputStream, .Reader, java.sql.Array, .Blob, .CallableStatement, .Clob, .Connection, .DatabaseMetaData, .NClob, .PreparedStatement, .ResultSet, .SQLClientInfoException, .SQLException, .SQLWarning, .SQLXML, .Savepoint, .Statement, .Struct, java.util.ArrayList, .Collections, .HashMap, .Map, .Objects, .Properties, java.util.concurrent.Executor, java.util.concurrent.locks.ReentrantLock, java.util.regex.Pattern, org.h2.api.ErrorCode, .JavaObjectSerializer, org.h2.command.CommandInterface, org.h2.engine.CastDataProvider, .ConnectionInfo, .Constants, .IsolationLevel, .Mode, .Session, .Session.StaticSettings, .SessionRemote, .SysProperties, org.h2.message.DbException, .TraceObject, org.h2.result.ResultInterface, org.h2.util.CloseWatcher, .TimeZoneProvider, org.h2.value.CompareMode, .Value, .ValueInteger, .ValueNull, .ValueTimestampTimeZone, .ValueToObjectConverter, .ValueVarbinary, .ValueVarchar

Represents a connection (session) to a database.

Thread safety: the connection is thread-safe. Different statements from the same connection may try to execute their commands in parallel, but they will be executed sequentially. If real concurrent execution of these commands is needed, different connections should be used.

Field Summary

Modifier and TypeField and Description
private String
private Map<String, String>
private CommandInterface
private Statement
private CommandInterface
private CommandInterface
private int
private static boolean
private final ReentrantLock
private static final String
private static final String
private int
private CommandInterface
private int
private Session
private CommandInterface
private final String
private final String
private final CloseWatcher
Inherited from org.h2.message.TraceObject:
ARRAYBLOBCALLABLE_STATEMENTCLOBCONNECTIONDATA_SOURCEDATABASE_META_DATAPARAMETER_META_DATAPREPARED_STATEMENTRESULT_SETRESULT_SET_META_DATASAVEPOINTSQLXMLSTATEMENTtraceXA_DATA_SOURCEXID

Constructor Summary

AccessConstructor and Description
public
JdbcConnection(String
of this connection
url
,
Properties
of this connection
info
,
String
of this connection
user
,
Object
for the user
password
,
boolean
whether database creation is forbidden
forbidCreation
)

INTERNAL the session closable object does not leak as Eclipse warns - due to the CloseWatcher.

public
JdbcConnection(JdbcConnection
connection to clone
clone
)

INTERNAL

public
JdbcConnection(Session
of this connection
session
,
String
of this connection
user
,
String
of this connection
url
)

INTERNAL

Method Summary

Modifier and TypeMethod and Description
public void
abort(Executor
the executor used by this method
executor
)

Implements java.sql.Connection.abort.

[Not supported]

protected void
checkClosed()

INTERNAL.

private static void
checkHoldability(int resultSetHoldability)

pack-priv static void
checkMap(Map<String, Class<?>>
the type map
map
)

Check that the given type map is either null or empty.

private static void
checkRunOver(int i, int len, String sql)

private static void
checkTypeConcurrency(int resultSetType, int resultSetConcurrency)

public void
clearWarnings()

Implements java.sql.Connection.clearWarnings.

Clears all warnings.

public void
close()

Implements java.sql.Connection.close.

Closes this connection.

private static CommandInterface
private void
private void
public void
commit()

Implements java.sql.Connection.commit.

Commits the current transaction.

private static JdbcSavepoint
private static SQLClientInfoException
public Array

Returns:

the array
createArrayOf
(String
the type name
typeName
,
Object[]
the values
elements
)

Implements java.sql.Connection.createArrayOf.

Create a new Array object.

public Blob

Returns:

the object
createBlob
()

Implements java.sql.Connection.createBlob.

Create a new empty Blob object.

pack-priv Value

Returns:

the value
createBlob
(InputStream
the input stream
x
,
long
the length (if smaller or equal than 0, all data until the end of file is read)
length
)

Create a Blob value from this input stream.

public Clob

Returns:

the object
createClob
()

Implements java.sql.Connection.createClob.

Create a new empty Clob object.

pack-priv Value

Returns:

the value
createClob
(Reader
the reader
x
,
long
the length (if smaller or equal than 0, all data until the end of file is read)
length
)

Create a Clob value from this reader.

public NClob

Returns:

the object
createNClob
()

Implements java.sql.Connection.createNClob.

Create a new empty NClob object.

public SQLXML

Returns:

the object
createSQLXML
()

Implements java.sql.Connection.createSQLXML.

Create a new SQLXML object with no data.

public Statement

Returns:

the new statement
createStatement
()

Implements java.sql.Connection.createStatement.

Creates a new statement.

public Statement

Returns:

the statement
createStatement
(int
the result set type (ResultSet.TYPE_*)
resultSetType
,
int
the concurrency (ResultSet.CONCUR_*)
resultSetConcurrency
)

Implements java.sql.Connection.createStatement.

Creates a statement with the specified result set type and concurrency.

public Statement

Returns:

the statement
createStatement
(int
the result set type (ResultSet.TYPE_*)
resultSetType
,
int
the concurrency (ResultSet.CONCUR_*)
resultSetConcurrency
,
int
the holdability (ResultSet.HOLD* / CLOSE*)
resultSetHoldability
)

Implements java.sql.Connection.createStatement.

Creates a statement with the specified result set type, concurrency, and holdability.

public Struct
createStruct(String
the SQL type name of the SQL structured type that this Struct object maps to. The typeName is the name of a user-defined type that has been defined for this database. It is the value returned by Struct.getSQLTypeName.
typeName
,
Object[]
the attributes that populate the returned object
attributes
)

Implements java.sql.Connection.createStruct.

[Not supported] Create a new empty Struct object.

public ValueTimestampTimeZone
currentTimestamp()

Implements org.h2.engine.CastDataProvider.currentTimestamp.

Returns the current timestamp with maximum resolution.

public TimeZoneProvider
currentTimeZone()

Implements org.h2.engine.CastDataProvider.currentTimeZone.

Returns the current time zone.

private static boolean
found(String sql, int start, String other)

public boolean

Returns:

true for on, false for off
getAutoCommit
()

Implements java.sql.Connection.getAutoCommit.

Gets the current setting for auto commit.

public String

Returns:

the catalog name
getCatalog
()

Implements java.sql.Connection.getCatalog.

Gets the current catalog name.

public Properties

Returns:

the property list
getClientInfo
()

Implements java.sql.Connection.getClientInfo.

Get the client properties.

public String

Returns:

the property value or null if the property is not found or not supported.
getClientInfo
(String
the client info name
name
)

Implements java.sql.Connection.getClientInfo.

Get a client property.

pack-priv CompareMode
public int

Returns:

the holdability
getHoldability
()

Implements java.sql.Connection.getHoldability.

Returns the current result set holdability.

public JavaObjectSerializer
getJavaObjectSerializer()

Implements org.h2.engine.CastDataProvider.getJavaObjectSerializer.

Returns the custom Java object serializer, or null.

public DatabaseMetaData

Returns:

the database meta data
getMetaData
()

Implements java.sql.Connection.getMetaData.

Gets the database meta data for this database.

public Mode
getMode()

Implements org.h2.engine.CastDataProvider.getMode.

Returns the database mode.

public int
pack-priv int
getQueryTimeout()

INTERNAL

public String

Returns:

current schema name
getSchema
()

Implements java.sql.Connection.getSchema.

Retrieves this current schema name for this connection.

public Session

Returns:

session
getSession
()

INTERNAL

public Session.StaticSettings

Returns:

StaticSettings
getStaticSettings
()

INTERNAL

public int

Returns:

the isolation level
getTransactionIsolation
()

Implements java.sql.Connection.getTransactionIsolation.

Returns the current transaction isolation level.

public Map<String, Class<?>>

Returns:

null
getTypeMap
()

Implements java.sql.Connection.getTypeMap.

Gets the type map.

pack-priv String
pack-priv String
public SQLWarning

Returns:

null
getWarnings
()

Implements java.sql.Connection.getWarnings.

Gets the first warning reported by calls on this object.

public boolean

Returns:

true if close was called
isClosed
()

Implements java.sql.Connection.isClosed.

Returns true if this connection has been closed.

private static boolean
public boolean

Returns:

if the database is read-only
isReadOnly
()

Implements java.sql.Connection.isReadOnly.

Returns true if the database is read-only.

public boolean

Returns:

true if the connection is valid.
isValid
(int
the number of seconds to wait for the database to respond (ignored)
timeout
)

Implements java.sql.Connection.isValid.

Returns true if this connection is still valid.

public boolean

Returns:

whether or not the interface is assignable from this class
isWrapperFor
(Class<?>
the class
iface
)

Implements java.sql.Wrapper.isWrapperFor.

Checks if unwrap can return an object of this class.

protected final void
lock()

Locks this connection with a reentrant lock.

public String

Returns:

the translated statement
nativeSQL
(String
the SQL statement with or without JDBC escape sequences
sql
)

Implements java.sql.Connection.nativeSQL.

Translates a SQL statement into the database grammar.

public CallableStatement

Returns:

the callable statement
prepareCall
(String
the SQL statement
sql
)

Implements java.sql.Connection.prepareCall.

Creates a new callable statement.

public CallableStatement

Returns:

the callable statement
prepareCall
(String
the SQL statement
sql
,
int
the result set type (ResultSet.TYPE_*)
resultSetType
,
int
the concurrency (ResultSet.CONCUR_*)
resultSetConcurrency
)

Implements java.sql.Connection.prepareCall.

Creates a callable statement with the specified result set type and concurrency.

public CallableStatement

Returns:

the callable statement
prepareCall
(String
the SQL statement
sql
,
int
the result set type (ResultSet.TYPE_*)
resultSetType
,
int
the concurrency (ResultSet.CONCUR_*)
resultSetConcurrency
,
int
the holdability (ResultSet.HOLD* / CLOSE*)
resultSetHoldability
)

Implements java.sql.Connection.prepareCall.

Creates a callable statement with the specified result set type, concurrency, and holdability.

pack-priv CommandInterface

Returns:

the command
prepareCommand
(String
the SQL statement
sql
,
int
the fetch size (used in remote connections)
fetchSize
)

Prepare an command.

private CommandInterface
public PreparedStatement

Returns:

the prepared statement
prepareStatement
(String
the SQL statement
sql
)

Implements java.sql.Connection.prepareStatement.

Creates a new prepared statement.

public PreparedStatement

Returns:

the prepared statement
prepareStatement
(String
the SQL statement
sql
,
int
the result set type (ResultSet.TYPE_*)
resultSetType
,
int
the concurrency (ResultSet.CONCUR_*)
resultSetConcurrency
)

Implements java.sql.Connection.prepareStatement.

Creates a prepared statement with the specified result set type and concurrency.

public PreparedStatement

Returns:

the prepared statement
prepareStatement
(String
the SQL statement
sql
,
int
the result set type (ResultSet.TYPE_*)
resultSetType
,
int
the concurrency (ResultSet.CONCUR_*)
resultSetConcurrency
,
int
the holdability (ResultSet.HOLD* / CLOSE*)
resultSetHoldability
)

Implements java.sql.Connection.prepareStatement.

Creates a prepared statement with the specified result set type, concurrency, and holdability.

public PreparedStatement

Returns:

the prepared statement
prepareStatement
(String
the SQL statement
sql
,
int
Statement#RETURN_GENERATED_KEYS if generated keys should be available for retrieval, Statement#NO_GENERATED_KEYS if generated keys should not be available
autoGeneratedKeys
)

Implements java.sql.Connection.prepareStatement.

Creates a new prepared statement.

public PreparedStatement

Returns:

the prepared statement
prepareStatement
(String
the SQL statement
sql
,
int[]
an array of column indexes indicating the columns with generated keys that should be returned from the inserted row
columnIndexes
)

Implements java.sql.Connection.prepareStatement.

Creates a new prepared statement.

public PreparedStatement

Returns:

the prepared statement
prepareStatement
(String
the SQL statement
sql
,
String[]
an array of column names indicating the columns with generated keys that should be returned from the inserted row
columnNames
)

Implements java.sql.Connection.prepareStatement.

Creates a new prepared statement.

public void
releaseSavepoint(Savepoint
the savepoint to release
savepoint
)

Implements java.sql.Connection.releaseSavepoint.

Releases a savepoint.

public void
rollback()

Implements java.sql.Connection.rollback.

Rolls back the current transaction.

public void
rollback(Savepoint
the savepoint
savepoint
)

Implements java.sql.Connection.rollback.

Rolls back to a savepoint.

private void
public void
setAutoCommit(boolean
true for auto commit on, false for off
autoCommit
)

Implements java.sql.Connection.setAutoCommit.

Switches auto commit on or off.

public void
setCatalog(String
ignored
catalog
)

Implements java.sql.Connection.setCatalog.

Set the default catalog name.

public void
setClientInfo(String
the name of the property
name
,
String
the value
value
)

Implements java.sql.Connection.setClientInfo.

Set a client property.

public void
setClientInfo(Properties
the properties (ignored)
properties
)

Implements java.sql.Connection.setClientInfo.

Set the client properties.

pack-priv void
public void
setHoldability(int
ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT;
holdability
)

Implements java.sql.Connection.setHoldability.

Changes the current result set holdability.

public void
setNetworkTimeout(Executor
the executor used by this method
executor
,
int
the TCP connection timeout
milliseconds
)

Implements java.sql.Connection.setNetworkTimeout.

[Not supported]

pack-priv void
setQueryTimeout(int seconds)

INTERNAL

public void
setReadOnly(boolean
ignored
readOnly
)

Implements java.sql.Connection.setReadOnly.

According to the JDBC specs, this setting is only a hint to the database to enable optimizations - it does not cause writes to be prohibited.

public Savepoint

Returns:

the new savepoint
setSavepoint
()

Implements java.sql.Connection.setSavepoint.

Creates a new unnamed savepoint.

public Savepoint

Returns:

the new savepoint
setSavepoint
(String
the savepoint name
name
)

Implements java.sql.Connection.setSavepoint.

Creates a new named savepoint.

public void
setSchema(String
the schema name
schema
)

Implements java.sql.Connection.setSchema.

Sets the given schema name to access.

public void
setTransactionIsolation(int
the new transaction isolation level: Connection.TRANSACTION_READ_UNCOMMITTED, Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_REPEATABLE_READ, 6 (SNAPSHOT), or Connection.TRANSACTION_SERIALIZABLE
level
)

Implements java.sql.Connection.setTransactionIsolation.

Changes the current transaction isolation level.

public void
setTypeMap(Map<String, Class<?>>
the java.util.Map object to install as the replacement for this Connection object's default type map
map
)

Implements java.sql.Connection.setTypeMap.

[Partially supported] Sets the type map.

public String
toString()

Overrides java.lang.Object.toString.

INTERNAL

private static int
translateGetEnd(String sql, int i, char c)

private static String

Returns:

the SQL statement without JDBC escape sequences
translateSQL
(String
the SQL statement with or without JDBC escape sequences
sql
)

Convert JDBC escape sequences in the SQL statement.

pack-priv static String

Returns:

the SQL statement without JDBC escape sequences
translateSQL
(String
the SQL statement with or without JDBC escape sequences
sql
,
boolean
whether escape sequences should be replaced
escapeProcessing
)

Convert JDBC escape sequences in the SQL statement if required.

private static String
protected final void
unlock()

Unlocks this connection.

public <T> T

Returns:

this
unwrap
(Class<T>
the class
iface
)

Implements java.sql.Wrapper.unwrap.

Return an object of this class if possible.

public boolean
zeroBasedEnums()

Implements org.h2.engine.CastDataProvider.zeroBasedEnums.

Returns are ENUM values 0-based.

Inherited from org.h2.message.TraceObject:
debugCodedebugCodeAssigndebugCodeCalldebugCodeCalldebugCodeCallgetNextIdgetTraceIdgetTraceObjectNameisDebugEnabledisInfoEnabledlogAndConvertquotequoteArrayquoteBigDecimalquoteBytesquoteDatequoteIntArrayquoteMapquoteTimequoteTimestampsetTraceunsupported