AutoCloseable, Connection, Wrapperpublic abstract class MonetConnection extends MonetWrapper implements Connection, AutoCloseable
Connection suitable for the MonetDB database.
This connection represents a connection (session) to a MonetDB
database. SQL statements are executed and results are returned within
the context of a connection. This Connection object holds a physical
connection to the MonetDB database.
A Connection object's database should able to provide information
describing its tables, its supported SQL grammar, its stored
procedures, the capabilities of this connection, and so on. This
information is obtained with the getMetaData method.
Note: By default a Connection object is in auto-commit mode, which
means that it automatically commits changes after executing each
statement. If auto-commit mode has been disabled, the method commit
must be called explicitly in order to commit changes; otherwise,
database changes will not be saved.
The current state of this connection is that it nearly implements the
whole Connection interface.| Modifier and Type | Class | Description |
|---|---|---|
class |
MonetConnection.ResponseList |
A list of Response objects.
|
| Modifier and Type | Field | Description |
|---|---|---|
protected Properties |
conn_props |
The successful processed input properties
|
protected String |
hash |
Authentication hash method
|
protected nl.cwi.monetdb.mcl.connection.IMonetDBLanguage |
language |
The language to connect with
|
protected nl.cwi.monetdb.mcl.protocol.AbstractProtocol |
protocol |
The underlying proticol provided by the connection (MAPI or embedded)
|
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE| Constructor | Description |
|---|---|
MonetConnection(Properties props,
String hash,
nl.cwi.monetdb.mcl.connection.IMonetDBLanguage language,
boolean blobIsBinary,
boolean clobIsLongChar) |
Constructor of a Connection for MonetDB.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
abort(Executor executor) |
Terminates an open connection.
|
void |
clearWarnings() |
Clears all warnings reported for this Connection object.
|
void |
close() |
Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be
automatically released.
|
abstract void |
closeUnderlyingConnection() |
Closes the underlying connection implementation.
|
void |
commit() |
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently
held by this Connection object.
|
abstract List<String> |
connect(String user,
String pass) |
Connects to the server, authenticating the user.
|
Array |
createArrayOf(String typeName,
Object[] elements) |
Factory method for creating Array objects.
|
Blob |
createBlob() |
Constructs an object that implements the Blob interface.
|
Clob |
createClob() |
Constructs an object that implements the Clob interface.
|
NClob |
createNClob() |
Constructs an object that implements the NClob interface.
|
SQLXML |
createSQLXML() |
Constructs an object that implements the SQLXML interface.
|
Statement |
createStatement() |
Creates a Statement object for sending SQL statements to the
database.
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency) |
Creates a Statement object that will generate ResultSet objects
with the given type and concurrency.
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
Creates a Statement object that will generate ResultSet objects
with the given type, concurrency, and holdability.
|
Struct |
createStruct(String typeName,
Object[] attributes) |
Factory method for creating Struct objects.
|
protected abstract boolean |
executeNextQueryBatch(MonetStatement statement,
List<String> batch,
int[] counts,
BatchUpdateException e) |
Execute a batch of SQL query statements.
|
protected void |
finalize() |
Destructor called by garbage collector before destroying this object tries to disconnect the MonetDB connection
if it has not been disconnected already.
|
boolean |
getAutoCommit() |
Retrieves the current auto-commit mode for this Connection object.
|
abstract int |
getBlockSize() |
Gets the underlying connection block size length.
|
String |
getCatalog() |
Retrieves this Connection object's current catalog name.
|
Properties |
getClientInfo() |
Returns a list containing the name and current value of each client info
property supported by the driver.
|
String |
getClientInfo(String name) |
Returns the value of the client info property specified by name.
|
abstract int |
getDefFetchsize() |
Gets the underlying connection default fetch size for DataBlock responses.
|
int |
getHoldability() |
Retrieves the current holdability of ResultSet objects created using this Connection object.
|
abstract String |
getJDBCURL() |
Gets the underlying connection JDBC String URL.
|
nl.cwi.monetdb.mcl.connection.IMonetDBLanguage |
getLanguage() |
Gets the connection's language data.
|
DatabaseMetaData |
getMetaData() |
Retrieves a DatabaseMetaData object that contains metadata about
the database to which this Connection object represents a
connection.
|
int |
getNetworkTimeout() |
Retrieves the number of milliseconds the driver will wait for a
database request to complete.
|
nl.cwi.monetdb.mcl.protocol.AbstractProtocol |
getProtocol() |
Gets the connection's protocol.
|
String |
getSchema() |
Retrieves this Connection object's current schema name.
|
static int |
getSeqCounter() |
Gets the current sequence counter.
|
abstract int |
getSoTimeout() |
Gets the underlying connection socket timeout.
|
int |
getTransactionIsolation() |
Retrieves this Connection object's current transaction isolation level.
|
Map<String,Class<?>> |
getTypeMap() |
Retrieves the Map object associated with this Connection object.
|
SQLWarning |
getWarnings() |
Retrieves the first warning reported by calls on this Connection
object.
|
abstract int |
initialStringBuilderSize() |
Gets the initial value for the StringBuilder size.
|
boolean |
isClosed() |
Retrieves whether this Connection object has been closed.
|
boolean |
isEmbedded() |
Checks if the conection is embedded or not
|
boolean |
isReadOnly() |
Retrieves whether this Connection object is in read-only mode.
|
boolean |
isValid(int timeout) |
Returns true if the connection has not been closed and is still
valid.
|
boolean |
mapBlobAsVarBinary() |
|
boolean |
mapClobAsVarChar() |
|
String |
nativeSQL(String sql) |
Converts the given SQL statement into the system's native SQL grammar.
|
CallableStatement |
prepareCall(String sql) |
Creates a CallableStatement object for calling database stored procedures.
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency) |
Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
|
PreparedStatement |
prepareStatement(String sql) |
Creates a PreparedStatement object for sending parameterized SQL
statements to the database.
|
PreparedStatement |
prepareStatement(String sql,
int autoGeneratedKeys) |
Creates a default PreparedStatement object that has the
capability to retrieve auto-generated keys.
|
PreparedStatement |
prepareStatement(String sql,
int[] columnIndexes) |
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency) |
Creates a PreparedStatement object that will generate ResultSet
objects with the given type and concurrency.
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
Creates a PreparedStatement object that will generate ResultSet
objects with the given type, concurrency, and holdability.
|
PreparedStatement |
prepareStatement(String sql,
String[] columnNames) |
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
|
void |
releaseSavepoint(Savepoint savepoint) |
Removes the given Savepoint object from the current transaction.
|
void |
rollback() |
Undoes all changes made in the current transaction and releases
any database locks currently held by this Connection object.
|
void |
rollback(Savepoint savepoint) |
Undoes all changes made after the given Savepoint object was set.
|
abstract void |
sendControlCommand(int commandID,
int data) |
Sends a control command to the server.
|
void |
setAutoCommit(boolean autoCommit) |
Sets this connection's auto-commit mode to the given state.
|
void |
setCatalog(String catalog) |
Sets the given catalog name in order to select a subspace of this
Connection object's database in which to work.
|
void |
setClientInfo(String name,
String value) |
Sets the value of the client info property specified by name to the value specified by value.
|
void |
setClientInfo(Properties props) |
Sets the value of the connection's client info properties.
|
void |
setHoldability(int holdability) |
Changes the default holdability of ResultSet objects created using this
Connection object to the given holdability.
|
void |
setNetworkTimeout(Executor executor,
int millis) |
Sets the maximum period a Connection or objects created from the
Connection will wait for the database to reply to any one
request.
|
void |
setReadOnly(boolean readOnly) |
Puts this connection in read-only mode as a hint to the driver to
enable database optimizations.
|
Savepoint |
setSavepoint() |
Creates an unnamed savepoint in the current transaction and
returns the new Savepoint object that represents it.
|
Savepoint |
setSavepoint(String name) |
Creates a savepoint with the given name in the current
transaction and returns the new Savepoint object that represents
it.
|
void |
setSchema(String schema) |
Sets the given schema name to access.
|
abstract void |
setSoTimeout(int timeout) |
Sets the underlying connection socket timeout.
|
void |
setTransactionIsolation(int level) |
Attempts to change the transaction isolation level for this
Connection object to the one given.
|
void |
setTypeMap(Map<String,Class<?>> map) |
Installs the given TypeMap object as the type map for this
Connection object.
|
String |
toString() |
Returns a string identifying this Connection to the MonetDB server.
|
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValidisWrapperFor, unwrapclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitisWrapperFor, unwrapprotected final Properties conn_props
protected nl.cwi.monetdb.mcl.connection.IMonetDBLanguage language
protected final String hash
protected nl.cwi.monetdb.mcl.protocol.AbstractProtocol protocol
public MonetConnection(Properties props, String hash, nl.cwi.monetdb.mcl.connection.IMonetDBLanguage language, boolean blobIsBinary, boolean clobIsLongChar)
public static int getSeqCounter()
public boolean isEmbedded()
public nl.cwi.monetdb.mcl.connection.IMonetDBLanguage getLanguage()
public nl.cwi.monetdb.mcl.protocol.AbstractProtocol getProtocol()
public abstract List<String> connect(String user, String pass) throws IOException, nl.cwi.monetdb.mcl.protocol.ProtocolException, nl.cwi.monetdb.mcl.connection.MCLException
user - The user name to authenticatepass - The user's passwordIOException - if an I/O error occurs when creating the socketnl.cwi.monetdb.mcl.protocol.ProtocolException - if bogus data is receivednl.cwi.monetdb.mcl.connection.MCLException - if an MCL related error occurspublic abstract int getBlockSize()
public abstract int getDefFetchsize()
public abstract int initialStringBuilderSize()
public abstract int getSoTimeout()
throws SocketException
SocketExceptionpublic abstract void setSoTimeout(int timeout)
throws SocketException
timeout - The specified timeout, in milliseconds. A timeout of zero is interpreted as an infinite timeoutSocketExceptionpublic abstract void closeUnderlyingConnection()
throws IOException
IOException - if an I/O error occurs while closing the connectionpublic abstract String getJDBCURL()
public abstract void sendControlCommand(int commandID,
int data)
throws SQLException
commandID - The command identifier according to ControlCommands listingdata - The integer to send according to the control commandSQLException - if an IO exception or a database error occursprotected abstract boolean executeNextQueryBatch(MonetStatement statement, List<String> batch, int[] counts, BatchUpdateException e) throws SQLException
statement - The original MonetStatement where the batch comes frombatch - The list of queries to executecounts - The return of the update statement of each input querye - An exception to be thrown if an error occursSQLException - if an IO exception or a database error occurspublic void close()
close in interface AutoCloseableclose in interface Connectionprotected void finalize()
throws Throwable
public void clearWarnings()
clearWarnings in interface Connectionpublic void commit()
throws SQLException
commit in interface ConnectionSQLException - if a database access error occurs or this Connection object is in auto-commit modesetAutoCommit(boolean)public Statement createStatement() throws SQLException
createStatement in interface ConnectionSQLException - if a database access error occurspublic Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
createStatement in interface ConnectionresultSetType - a result set type; one of
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
or ResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency - a concurrency type; one of
ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLESQLException - if a database access error occurspublic Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
createStatement in interface ConnectionresultSetType - one of the following ResultSet constants:
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
or ResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency - one of the following ResultSet
constants: ResultSet.CONCUR_READ_ONLY or
ResultSet.CONCUR_UPDATABLEresultSetHoldability - one of the following ResultSet
constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMITSQLException - if a database access error occurs or the
given parameters are not ResultSet constants indicating type,
concurrency, and holdabilitypublic boolean getAutoCommit()
throws SQLException
getAutoCommit in interface ConnectionSQLExceptionsetAutoCommit(boolean)public String getCatalog() throws SQLException
getCatalog in interface ConnectionSQLException - if a database access error occurs or the current language is not SQLpublic int getHoldability()
getHoldability in interface ConnectionsetHoldability(int)public DatabaseMetaData getMetaData() throws SQLException
getMetaData in interface ConnectionSQLException - if the current language is not SQLpublic int getTransactionIsolation()
getTransactionIsolation in interface Connectionpublic Map<String,Class<?>> getTypeMap()
getTypeMap in interface Connectionpublic SQLWarning getWarnings() throws SQLException
getWarnings in interface ConnectionSQLException - if a database access error occurs or this method is called on a closed connectionpublic boolean isClosed()
isClosed in interface Connectionpublic boolean isReadOnly()
isReadOnly in interface Connectionpublic String nativeSQL(String sql)
nativeSQL in interface Connectionpublic CallableStatement prepareCall(String sql) throws SQLException
prepareCall in interface ConnectionSQLExceptionpublic CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
prepareCall in interface ConnectionSQLExceptionpublic CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
prepareCall in interface ConnectionSQLExceptionpublic PreparedStatement prepareStatement(String sql) throws SQLException
prepareStatement in interface Connectionsql - an SQL statement that may contain one or more '?' IN
parameter placeholdersSQLException - if a database access error occurspublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
prepareStatement in interface Connectionsql - a String object that is the SQL statement to be sent to the
database; may contain one or more ? IN parametersresultSetType - a result set type; one of
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
or ResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency - a concurrency type; one of
ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLESQLException - if a database access error occurs or the given
parameters are not ResultSet constants indicating
type and concurrencypublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
prepareStatement in interface Connectionsql - a String object that is the SQL statement to be sent
to the database; may contain one or more ? IN parametersresultSetType - one of the following ResultSet constants:
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
or ResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency - one of the following ResultSet
constants: ResultSet.CONCUR_READ_ONLY or
ResultSet.CONCUR_UPDATABLEresultSetHoldability - one of the following ResultSet
constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMITSQLException - if a database access error occurs or the
given parameters are not ResultSet constants indicating type,
concurrency, and holdabilitypublic PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
prepareStatement in interface Connectionsql - an SQL statement that may contain one or more '?' IN
parameter placeholdersautoGeneratedKeys - a flag indicating whether auto-generated
keys should be returned; one of
Statement.RETURN_GENERATED_KEYS or
Statement.NO_GENERATED_KEYSSQLException - - if a database access error occurs or the
given parameter is not a Statement constant indicating
whether auto-generated keys should be returnedpublic PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
prepareStatement in interface ConnectionSQLExceptionpublic PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
prepareStatement in interface ConnectionSQLExceptionpublic void releaseSavepoint(Savepoint savepoint) throws SQLException
releaseSavepoint in interface Connectionsavepoint - the Savepoint object to be removedSQLException - if a database access error occurs or the given
Savepoint object is not a valid savepoint in the current
transactionpublic void rollback()
throws SQLException
rollback in interface ConnectionSQLException - if a database access error occurs or this
Connection object is in auto-commit modesetAutoCommit(boolean)public void rollback(Savepoint savepoint) throws SQLException
rollback in interface Connectionsavepoint - the Savepoint object to roll back toSQLException - if a database access error occurs, the
Savepoint object is no longer valid, or this Connection
object is currently in auto-commit modepublic void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit in interface ConnectionautoCommit - true to enable auto-commit mode; false to disable itSQLException - if a database access error occursgetAutoCommit()public void setCatalog(String catalog) throws SQLException
setCatalog in interface ConnectionSQLExceptionpublic void setHoldability(int holdability)
throws SQLException
setHoldability in interface Connectionholdability - - a ResultSet holdability constant; one of
ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMITSQLExceptiongetHoldability()public void setReadOnly(boolean readOnly)
throws SQLException
setReadOnly in interface ConnectionreadOnly - true enables read-only mode; false disables itSQLException - if a database access error occurs or this
method is called during a transaction.public Savepoint setSavepoint() throws SQLException
setSavepoint in interface ConnectionSQLException - if a database access error occurs or this Connection
object is currently in auto-commit modepublic Savepoint setSavepoint(String name) throws SQLException
setSavepoint in interface Connectionname - a String containing the name of the savepointSQLException - if a database access error occurs or this Connection
object is currently in auto-commit modepublic void setTransactionIsolation(int level)
setTransactionIsolation in interface Connectionlevel - one of the following Connection constants: Connection.TRANSACTION_READ_UNCOMMITTED,
Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_REPEATABLE_READ, or
Connection.TRANSACTION_SERIALIZABLE.public void setTypeMap(Map<String,Class<?>> map)
setTypeMap in interface Connectionmap - the java.util.Map object to install as the replacement for
this Connection object's default type mappublic String toString()
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
createArrayOf in interface ConnectiontypeName - the SQL name of the type the elements of the
array map to. The typeName is a database-specific name
which may be the name of a built-in type, a user-defined
type or a standard SQL type supported by this database.
This is the value returned by Array.getBaseTypeNameSQLException - if a database error occurs, the JDBC type
is not appropriate for the typeName and the conversion is
not supported, the typeName is null or this method is
called on a closed connectionSQLFeatureNotSupportedException - the JDBC driver does
not support this data typepublic Clob createClob() throws SQLException
createClob in interface ConnectionSQLFeatureNotSupportedException - the JDBC driver does
not support MonetClob objects that can be filled inSQLExceptionpublic Blob createBlob() throws SQLException
createBlob in interface ConnectionSQLFeatureNotSupportedException - the JDBC driver does
not support MonetBlob objects that can be filled inSQLExceptionpublic NClob createNClob() throws SQLException
createNClob in interface ConnectionSQLFeatureNotSupportedException - the JDBC driver does
not support MonetNClob objects that can be filled inSQLExceptionpublic Struct createStruct(String typeName, Object[] attributes) throws SQLException
createStruct in interface ConnectiontypeName - 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.attributes - the attributes that populate the returned objectSQLException - if a database error occurs, the typeName
is null or this method is called on a closed connectionSQLFeatureNotSupportedException - the JDBC driver does
not support this data typepublic SQLXML createSQLXML() throws SQLException
createSQLXML in interface ConnectionSQLFeatureNotSupportedException - the JDBC driver does
not support this data typeSQLExceptionpublic boolean isValid(int timeout)
throws SQLException
isValid in interface Connectiontimeout - The time in seconds to wait for the database
operation used to validate the connection to complete. If
the timeout period expires before the operation completes,
this method returns false. A value of 0 indicates a
timeout is not applied to the database operation.SQLException - if the value supplied for timeout is less than 0public String getClientInfo(String name) throws SQLException
getClientInfo in interface Connectionname - - The name of the client info property to retrieveSQLException - - if the database server returns an error
when fetching the client info value from the database
or this method is called on a closed connectionpublic Properties getClientInfo() throws SQLException
getClientInfo in interface ConnectionSQLException - - if the database server returns an error
when fetching the client info value from the database
or this method is called on a closed connectionpublic void setClientInfo(String name, String value) throws SQLClientInfoException
setClientInfo in interface Connectionname - - The name of the client info property to setvalue - - The value to set the client info property to. If the
value is null, the current value of the specified property is cleared.SQLClientInfoException - - if the database server returns an error
while setting the clientInfo values on the database server
or this method is called on a closed connectionpublic void setClientInfo(Properties props) throws SQLClientInfoException
setClientInfo in interface Connectionprops - - The list of client info properties to setSQLClientInfoException - - if the database server returns an error
while setting the clientInfo values on the database server
or this method is called on a closed connectionpublic void setSchema(String schema) throws SQLException
setSchema in interface Connectionschema - the name of a schema in which to workSQLException - if a database access error occurs or this method is called on a closed connectionpublic String getSchema() throws SQLException
getSchema in interface ConnectionSQLException - if a database access error occurs or this method is called on a closed connectionpublic void abort(Executor executor) throws SQLException
abort in interface Connectionexecutor - The Executor implementation which will be used by abortSQLException - if a database access error occurs or the executor is nullSecurityException - if a security manager exists and its checkPermission method denies calling abortpublic void setNetworkTimeout(Executor executor, int millis) throws SQLException
setNetworkTimeout in interface Connectionexecutor - The Executor implementation which will be used by setNetworkTimeoutmillis - The time in milliseconds to wait for the database operation to completeSQLException - if a database access error occurs, this method is called on a closed connection, the
executor is null, or the value specified for seconds is less than 0.public int getNetworkTimeout()
throws SQLException
getNetworkTimeout in interface ConnectionSQLException - if a database access error occurs or
this method is called on a closed Connectionpublic boolean mapBlobAsVarBinary()
public boolean mapClobAsVarChar()
Copyright © 2018. All rights reserved.