Package org.mariadb.jdbc
Class Connection
java.lang.Object
org.mariadb.jdbc.Connection
- All Implemented Interfaces:
AutoCloseable,Connection,Wrapper
Public Connection class
-
Field Summary
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE -
Constructor Summary
ConstructorsConstructorDescriptionConnection(Configuration conf, ClosableLock lock, org.mariadb.jdbc.client.Client client) Connection construction. -
Method Summary
Modifier and TypeMethodDescriptionfor _TEST_ onlyvoidbooleanvoidCancels the current query - clones the current protocol and executes a query using the new connection.voidvoidclose()voidcommit()createArrayOf(String typeName, Object elements) createArrayOf(String typeName, Object[] elements) createStatement(int resultSetType, int resultSetConcurrency) createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) createStruct(String typeName, Object[] attributes) voidFire event to indicate to StatementEventListeners registered on the connection that a PreparedStatement is closed.booleanorg.mariadb.jdbc.client.ClientAssociate connection clientgetClientInfo(String name) org.mariadb.jdbc.client.ContextConnection context.protected ExceptionFactoryGet connection exception factoryintprotected ClosableLockgetLock()Internal : retrieve internal ClosableLockintAre table case-sensitive or not .intlongCurrent server thread id.inthandleTimeout(int queryTimeout) Return a QueryTimeoutHandler for old server that don't support Statement timeout.booleanisClosed()booleanbooleanisValid(int timeout) booleanisWrapperFor(Class<?> iface) prepareCall(String sql) prepareCall(String sql, int resultSetType, int resultSetConcurrency) prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareInternal(String sql, int autoGeneratedKeys, int resultSetType, int resultSetConcurrency, boolean useBinary) Prepare statement creationprepareStatement(String sql) prepareStatement(String sql, int autoGeneratedKeys) prepareStatement(String sql, int[] columnIndexes) prepareStatement(String sql, int resultSetType, int resultSetConcurrency) prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement(String sql, String[] columnNames) voidreleaseSavepoint(Savepoint savepoint) voidreset()Reset connection set has it was after creating a "fresh" new connection.voidrollback()voidvoidsetAutoCommit(boolean autoCommit) voidsetCatalog(String catalog) voidsetClientInfo(String name, String value) voidsetClientInfo(Properties properties) voidsetHoldability(int holdability) voidsetNetworkTimeout(Executor executor, int milliseconds) voidsetPoolConnection(MariaDbPoolConnection poolConnection) Internal method.voidsetReadOnly(boolean readOnly) setSavepoint(String name) voidvoidsetTransactionIsolation(int level) voidsetTypeMap(Map<String, Class<?>> map) <T> TbooleanbooleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
Constructor Details
-
Connection
Connection construction.- Parameters:
conf- configurationlock- thread safe lockerclient- client object
-
-
Method Details
-
setPoolConnection
Internal method. Indicate that connection is created from internal pool- Parameters:
poolConnection- PoolConnection
-
cancelCurrentQuery
Cancels the current query - clones the current protocol and executes a query using the new connection.- Throws:
SQLException- never thrown
-
createStatement
- Specified by:
createStatementin interfaceConnection
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareInternal
public PreparedStatement prepareInternal(String sql, int autoGeneratedKeys, int resultSetType, int resultSetConcurrency, boolean useBinary) throws SQLException Prepare statement creation- Parameters:
sql- sqlautoGeneratedKeys- auto generated key requiredresultSetType- result-set typeresultSetConcurrency- concurrencyuseBinary- use server prepare statement- Returns:
- prepared statement
- Throws:
SQLException- if Prepare fails
-
prepareCall
- Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
nativeSQL
- Specified by:
nativeSQLin interfaceConnection- Throws:
SQLException
-
getAutoCommit
- Specified by:
getAutoCommitin interfaceConnection- Throws:
SQLException
-
setAutoCommit
- Specified by:
setAutoCommitin interfaceConnection- Throws:
SQLException
-
commit
- Specified by:
commitin interfaceConnection- Throws:
SQLException
-
rollback
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Throws:
SQLException
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceConnection
-
getContext
public org.mariadb.jdbc.client.Context getContext()Connection context.- Returns:
- connection context.
-
getLowercaseTableNames
Are table case-sensitive or not . Default Value: 0 (Unix), 1 (Windows), 2 (Mac OS X). If set to 0 (the default on Unix-based systems), table names and aliases and database names are compared in a case-sensitive manner. If set to 1 (the default on Windows), names are stored in lowercase and not compared in a case-sensitive manner. If set to 2 (the default on Mac OS X), names are stored as declared, but compared in lowercase.- Returns:
- int value.
- Throws:
SQLException- if a connection error occur
-
getMetaData
- Specified by:
getMetaDatain interfaceConnection
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfaceConnection
-
setReadOnly
- Specified by:
setReadOnlyin interfaceConnection- Throws:
SQLException
-
getCatalog
- Specified by:
getCatalogin interfaceConnection- Throws:
SQLException
-
setCatalog
- Specified by:
setCatalogin interfaceConnection- Throws:
SQLException
-
getSchema
- Specified by:
getSchemain interfaceConnection- Throws:
SQLException
-
setSchema
- Specified by:
setSchemain interfaceConnection- Throws:
SQLException
-
getTransactionIsolation
- Specified by:
getTransactionIsolationin interfaceConnection- Throws:
SQLException
-
setTransactionIsolation
- Specified by:
setTransactionIsolationin interfaceConnection- Throws:
SQLException
-
getWarnings
- Specified by:
getWarningsin interfaceConnection- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarningsin interfaceConnection- Throws:
SQLException
-
createStatement
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
getTypeMap
- Specified by:
getTypeMapin interfaceConnection
-
setTypeMap
- Specified by:
setTypeMapin interfaceConnection- Throws:
SQLException
-
getHoldability
public int getHoldability()- Specified by:
getHoldabilityin interfaceConnection
-
setHoldability
public void setHoldability(int holdability) - Specified by:
setHoldabilityin interfaceConnection
-
setSavepoint
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
rollback
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
releaseSavepoint
- Specified by:
releaseSavepointin interfaceConnection- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
createClob
- Specified by:
createClobin interfaceConnection
-
createBlob
- Specified by:
createBlobin interfaceConnection
-
createNClob
- Specified by:
createNClobin interfaceConnection
-
createSQLXML
- Specified by:
createSQLXMLin interfaceConnection- Throws:
SQLException
-
isValid
- Specified by:
isValidin interfaceConnection- Throws:
SQLException
-
setClientInfo
- Specified by:
setClientInfoin interfaceConnection
-
getClientInfo
- Specified by:
getClientInfoin interfaceConnection
-
getClientInfo
- Specified by:
getClientInfoin interfaceConnection
-
setClientInfo
- Specified by:
setClientInfoin interfaceConnection
-
createArrayOf
- Specified by:
createArrayOfin interfaceConnection- Throws:
SQLException
-
createArrayOf
- Throws:
SQLException
-
createStruct
- Specified by:
createStructin interfaceConnection- Throws:
SQLException
-
abort
- Specified by:
abortin interfaceConnection- Throws:
SQLException
-
setNetworkTimeout
- Specified by:
setNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
getNetworkTimeout
public int getNetworkTimeout()- Specified by:
getNetworkTimeoutin interfaceConnection
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper
-
getClient
public org.mariadb.jdbc.client.Client getClient()Associate connection client- Returns:
- connection client
-
reset
Reset connection set has it was after creating a "fresh" new connection. defaultTransactionIsolation must have been initialized.BUT : - session variable state are reset only if option useResetConnection is set and - if using the option "useServerPrepStmts", PREPARE statement are still prepared
- Throws:
SQLException- if resetting operation failed
-
getThreadId
public long getThreadId()Current server thread id.- Returns:
- current server thread id
-
fireStatementClosed
Fire event to indicate to StatementEventListeners registered on the connection that a PreparedStatement is closed.- Parameters:
prep- prepare statement closing
-
getExceptionFactory
Get connection exception factory- Returns:
- connection exception factory
-
handleTimeout
Return a QueryTimeoutHandler for old server that don't support Statement timeout.- Parameters:
queryTimeout- query timeout- Returns:
- a query timeout handler
-
getLock
Internal : retrieve internal ClosableLock- Returns:
- ClosableLock
-
useServerTimeout
public boolean useServerTimeout() -
cachePrepStmts
public boolean cachePrepStmts() -
useServerMaxRows
public boolean useServerMaxRows() -
__test_host
for _TEST_ only- Returns:
- current host
-