Package org.mariadb.jdbc
Class Connection
- java.lang.Object
-
- org.mariadb.jdbc.Connection
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.sql.Connection,java.sql.Wrapper
public class Connection extends java.lang.Object implements java.sql.Connection
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classConnection.SavepointInternal Savepoint implementation
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternCALLABLE_STATEMENT_PATTERNprivate booleancanUseServerMaxRowsprivate booleancanUseServerTimeoutprivate Clientclientprivate java.util.PropertiesclientInfoprivate Configurationconfprivate intdefaultFetchSizeprivate ExceptionFactoryexceptionFactoryprivate java.util.concurrent.locks.ReentrantLocklockprivate intlowercaseTableNamesprivate MariaDbPoolConnectionpoolConnectionprivate booleanreadOnlyprivate java.util.concurrent.atomic.AtomicIntegersavepointId
-
Constructor Summary
Constructors Constructor Description Connection(Configuration conf, java.util.concurrent.locks.ReentrantLock lock, Client client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(java.util.concurrent.Executor executor)voidcancelCurrentQuery()Cancels the current query - clones the current protocol and executes a query using the new connection.private voidcheckNotClosed()voidclearWarnings()voidclose()voidcommit()java.sql.ArraycreateArrayOf(java.lang.String typeName, java.lang.Object[] elements)java.sql.BlobcreateBlob()java.sql.ClobcreateClob()java.sql.NClobcreateNClob()java.sql.SQLXMLcreateSQLXML()StatementcreateStatement()StatementcreateStatement(int resultSetType, int resultSetConcurrency)StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.StructcreateStruct(java.lang.String typeName, java.lang.Object[] attributes)voidfireStatementClosed(java.sql.PreparedStatement prep)booleangetAutoCommit()java.lang.StringgetCatalog()ClientgetClient()java.util.PropertiesgetClientInfo()java.lang.StringgetClientInfo(java.lang.String name)ContextgetContext()protected ExceptionFactorygetExceptionFactory()intgetHoldability()intgetLowercaseTableNames()Are table case-sensitive or not .DatabaseMetaDatagetMetaData()intgetNetworkTimeout()java.lang.StringgetSchema()longgetThreadId()intgetTransactionIsolation()java.util.Map<java.lang.String,java.lang.Class<?>>getTypeMap()intgetWaitTimeout()java.sql.SQLWarninggetWarnings()booleanisClosed()booleanisReadOnly()booleanisValid(int timeout)booleanisWrapperFor(java.lang.Class<?> iface)java.lang.StringnativeSQL(java.lang.String sql)java.sql.CallableStatementprepareCall(java.lang.String sql)java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.PreparedStatementprepareInternal(java.lang.String sql, int autoGeneratedKeys, int resultSetType, int resultSetConcurrency, boolean useBinary)java.sql.PreparedStatementprepareStatement(java.lang.String sql)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int autoGeneratedKeys)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int[] columnIndexes)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.PreparedStatementprepareStatement(java.lang.String sql, java.lang.String[] columnNames)voidreleaseSavepoint(java.sql.Savepoint savepoint)voidreset()Reset connection set has it was after creating a "fresh" new connection.voidrollback()voidrollback(java.sql.Savepoint savepoint)voidsetAutoCommit(boolean autoCommit)voidsetCatalog(java.lang.String catalog)voidsetClientInfo(java.lang.String name, java.lang.String value)voidsetClientInfo(java.util.Properties properties)voidsetHoldability(int holdability)voidsetNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds)voidsetPoolConnection(MariaDbPoolConnection poolConnection)voidsetReadOnly(boolean readOnly)Connection.SavepointsetSavepoint()Connection.SavepointsetSavepoint(java.lang.String name)voidsetSchema(java.lang.String schema)voidsetTransactionIsolation(int level)voidsetTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> map)<T> Tunwrap(java.lang.Class<T> iface)
-
-
-
Field Detail
-
CALLABLE_STATEMENT_PATTERN
private static final java.util.regex.Pattern CALLABLE_STATEMENT_PATTERN
-
lock
private final java.util.concurrent.locks.ReentrantLock lock
-
conf
private final Configuration conf
-
exceptionFactory
private ExceptionFactory exceptionFactory
-
client
private final Client client
-
clientInfo
private final java.util.Properties clientInfo
-
lowercaseTableNames
private int lowercaseTableNames
-
savepointId
private final java.util.concurrent.atomic.AtomicInteger savepointId
-
readOnly
private boolean readOnly
-
canUseServerTimeout
private final boolean canUseServerTimeout
-
canUseServerMaxRows
private final boolean canUseServerMaxRows
-
defaultFetchSize
private final int defaultFetchSize
-
poolConnection
private MariaDbPoolConnection poolConnection
-
-
Constructor Detail
-
Connection
public Connection(Configuration conf, java.util.concurrent.locks.ReentrantLock lock, Client client)
-
-
Method Detail
-
setPoolConnection
public void setPoolConnection(MariaDbPoolConnection poolConnection)
-
cancelCurrentQuery
public void cancelCurrentQuery() throws java.sql.SQLExceptionCancels the current query - clones the current protocol and executes a query using the new connection.- Throws:
java.sql.SQLException- never thrown
-
createStatement
public Statement createStatement()
- Specified by:
createStatementin interfacejava.sql.Connection
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareInternal
public java.sql.PreparedStatement prepareInternal(java.lang.String sql, int autoGeneratedKeys, int resultSetType, int resultSetConcurrency, boolean useBinary) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException- Specified by:
prepareCallin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException- Specified by:
nativeSQLin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getAutoCommit
public boolean getAutoCommit()
- Specified by:
getAutoCommitin interfacejava.sql.Connection
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException- Specified by:
setAutoCommitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
commit
public void commit() throws java.sql.SQLException- Specified by:
commitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
rollback
public void rollback() throws java.sql.SQLException- Specified by:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
close
public void close() throws java.sql.SQLException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
isClosed
public boolean isClosed()
- Specified by:
isClosedin interfacejava.sql.Connection
-
getContext
public Context getContext()
-
getLowercaseTableNames
public int getLowercaseTableNames() throws java.sql.SQLExceptionAre 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:
java.sql.SQLException- if a connection error occur
-
getMetaData
public DatabaseMetaData getMetaData()
- Specified by:
getMetaDatain interfacejava.sql.Connection
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnlyin interfacejava.sql.Connection
-
setReadOnly
public void setReadOnly(boolean readOnly) throws java.sql.SQLException- Specified by:
setReadOnlyin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLException- Specified by:
getCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException- Specified by:
setCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws java.sql.SQLException- Specified by:
getTransactionIsolationin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLException- Specified by:
setTransactionIsolationin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException- Specified by:
getWarningsin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
clearWarnings
public void clearWarnings()
- Specified by:
clearWarningsin interfacejava.sql.Connection
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
createStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException- Specified by:
prepareCallin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getTypeMap
public java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap()
- Specified by:
getTypeMapin interfacejava.sql.Connection
-
setTypeMap
public void setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> map) throws java.sql.SQLException- Specified by:
setTypeMapin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getHoldability
public int getHoldability()
- Specified by:
getHoldabilityin interfacejava.sql.Connection
-
setHoldability
public void setHoldability(int holdability)
- Specified by:
setHoldabilityin interfacejava.sql.Connection
-
setSavepoint
public Connection.Savepoint setSavepoint() throws java.sql.SQLException
- Specified by:
setSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSavepoint
public Connection.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
- Specified by:
setSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
rollback
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException- Specified by:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException- Specified by:
releaseSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
createStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException- Specified by:
prepareCallin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createClob
public java.sql.Clob createClob()
- Specified by:
createClobin interfacejava.sql.Connection
-
createBlob
public java.sql.Blob createBlob()
- Specified by:
createBlobin interfacejava.sql.Connection
-
createNClob
public java.sql.NClob createNClob()
- Specified by:
createNClobin interfacejava.sql.Connection
-
createSQLXML
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException- Specified by:
createSQLXMLin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
checkNotClosed
private void checkNotClosed() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
isValid
public boolean isValid(int timeout) throws java.sql.SQLException- Specified by:
isValidin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setClientInfo
public void setClientInfo(java.lang.String name, java.lang.String value)- Specified by:
setClientInfoin interfacejava.sql.Connection
-
getClientInfo
public java.lang.String getClientInfo(java.lang.String name)
- Specified by:
getClientInfoin interfacejava.sql.Connection
-
getClientInfo
public java.util.Properties getClientInfo()
- Specified by:
getClientInfoin interfacejava.sql.Connection
-
setClientInfo
public void setClientInfo(java.util.Properties properties)
- Specified by:
setClientInfoin interfacejava.sql.Connection
-
createArrayOf
public java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements) throws java.sql.SQLException- Specified by:
createArrayOfin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStruct
public java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes) throws java.sql.SQLException- Specified by:
createStructin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getSchema
public java.lang.String getSchema()
- Specified by:
getSchemain interfacejava.sql.Connection
-
setSchema
public void setSchema(java.lang.String schema)
- Specified by:
setSchemain interfacejava.sql.Connection
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException- Specified by:
abortin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException- Specified by:
setNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout()
- Specified by:
getNetworkTimeoutin interfacejava.sql.Connection
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface)
- Specified by:
isWrapperForin interfacejava.sql.Wrapper
-
getWaitTimeout
public int getWaitTimeout()
-
getClient
public Client getClient()
-
reset
public void reset() throws java.sql.SQLExceptionReset 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:
java.sql.SQLException- if resetting operation failed
-
getThreadId
public long getThreadId()
-
fireStatementClosed
public void fireStatementClosed(java.sql.PreparedStatement prep)
-
getExceptionFactory
protected ExceptionFactory getExceptionFactory()
-
-