Package org.mariadb.jdbc
Class Connection
java.lang.Object
org.mariadb.jdbc.Connection
- All Implemented Interfaces:
AutoCloseable
,Connection
,Wrapper
Public Connection class
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
Internal Savepoint implementation -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Pattern
private final boolean
private final boolean
private final boolean
private final Client
private final Properties
private final Configuration
private final int
private ExceptionFactory
private final boolean
private final ClosableLock
private int
private MariaDbPoolConnection
private QueryTimeoutHandler
private boolean
private final AtomicInteger
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, Client client) Connection construction. -
Method Summary
Modifier and TypeMethodDescriptionfor _TEST_ onlyvoid
void
Cancels the current query - clones the current protocol and executes a query using the new connection.private void
void
void
close()
void
commit()
createArrayOf
(String typeName, Object[] elements) createStatement
(int resultSetType, int resultSetConcurrency) createStatement
(int resultSetType, int resultSetConcurrency, int resultSetHoldability) createStruct
(String typeName, Object[] attributes) void
Fire event to indicate to StatementEventListeners registered on the connection that a PreparedStatement is closed.boolean
Associate connection clientgetClientInfo
(String name) Connection context.private String
protected ExceptionFactory
Get connection exception factoryint
int
Are table case-sensitive or not .int
long
Current server thread id.int
handleTimeout
(int queryTimeout) boolean
isClosed()
boolean
boolean
isValid
(int timeout) boolean
isWrapperFor
(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) void
releaseSavepoint
(Savepoint savepoint) void
reset()
Reset connection set has it was after creating a "fresh" new connection.void
rollback()
void
void
setAutoCommit
(boolean autoCommit) void
setCatalog
(String catalog) void
setClientInfo
(String name, String value) void
setClientInfo
(Properties properties) private void
setDatabase
(String database) void
setHoldability
(int holdability) void
setNetworkTimeout
(Executor executor, int milliseconds) void
setPoolConnection
(MariaDbPoolConnection poolConnection) Internal method.void
setReadOnly
(boolean readOnly) setSavepoint
(String name) void
void
setTransactionIsolation
(int level) void
setTypeMap
(Map<String, Class<?>> map) <T> T
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
Field Details
-
CALLABLE_STATEMENT_PATTERN
-
lock
-
conf
-
client
-
clientInfo
-
savepointId
-
canUseServerTimeout
private final boolean canUseServerTimeout -
canCachePrepStmts
private final boolean canCachePrepStmts -
canUseServerMaxRows
private final boolean canUseServerMaxRows -
defaultFetchSize
private final int defaultFetchSize -
forceTransactionEnd
private final boolean forceTransactionEnd -
exceptionFactory
-
lowercaseTableNames
private int lowercaseTableNames -
readOnly
private boolean readOnly -
poolConnection
-
queryTimeoutHandler
-
-
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:
createStatement
in interfaceConnection
-
prepareStatement
- Specified by:
prepareStatement
in 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:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
nativeSQL
- Specified by:
nativeSQL
in interfaceConnection
- Throws:
SQLException
-
getAutoCommit
public boolean getAutoCommit()- Specified by:
getAutoCommit
in interfaceConnection
-
setAutoCommit
- Specified by:
setAutoCommit
in interfaceConnection
- Throws:
SQLException
-
commit
- Specified by:
commit
in interfaceConnection
- Throws:
SQLException
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
- Throws:
SQLException
-
isClosed
public boolean isClosed()- Specified by:
isClosed
in interfaceConnection
-
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:
getMetaData
in interfaceConnection
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnly
in interfaceConnection
-
setReadOnly
- Specified by:
setReadOnly
in interfaceConnection
- Throws:
SQLException
-
getCatalog
- Specified by:
getCatalog
in interfaceConnection
- Throws:
SQLException
-
setCatalog
- Specified by:
setCatalog
in interfaceConnection
- Throws:
SQLException
-
getSchema
- Specified by:
getSchema
in interfaceConnection
- Throws:
SQLException
-
setSchema
- Specified by:
setSchema
in interfaceConnection
- Throws:
SQLException
-
getDatabase
- Throws:
SQLException
-
setDatabase
- Throws:
SQLException
-
getTransactionIsolation
- Specified by:
getTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
setTransactionIsolation
- Specified by:
setTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
getWarnings
- Specified by:
getWarnings
in interfaceConnection
- Throws:
SQLException
-
clearWarnings
public void clearWarnings()- Specified by:
clearWarnings
in interfaceConnection
-
createStatement
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
getTypeMap
- Specified by:
getTypeMap
in interfaceConnection
-
setTypeMap
- Specified by:
setTypeMap
in interfaceConnection
- Throws:
SQLException
-
getHoldability
public int getHoldability()- Specified by:
getHoldability
in interfaceConnection
-
setHoldability
public void setHoldability(int holdability) - Specified by:
setHoldability
in interfaceConnection
-
setSavepoint
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
releaseSavepoint
- Specified by:
releaseSavepoint
in interfaceConnection
- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
createClob
- Specified by:
createClob
in interfaceConnection
-
createBlob
- Specified by:
createBlob
in interfaceConnection
-
createNClob
- Specified by:
createNClob
in interfaceConnection
-
createSQLXML
- Specified by:
createSQLXML
in interfaceConnection
- Throws:
SQLException
-
checkNotClosed
- Throws:
SQLException
-
isValid
- Specified by:
isValid
in interfaceConnection
- Throws:
SQLException
-
setClientInfo
- Specified by:
setClientInfo
in interfaceConnection
-
getClientInfo
- Specified by:
getClientInfo
in interfaceConnection
-
getClientInfo
- Specified by:
getClientInfo
in interfaceConnection
-
setClientInfo
- Specified by:
setClientInfo
in interfaceConnection
-
createArrayOf
- Specified by:
createArrayOf
in interfaceConnection
- Throws:
SQLException
-
createStruct
- Specified by:
createStruct
in interfaceConnection
- Throws:
SQLException
-
abort
- Specified by:
abort
in interfaceConnection
- Throws:
SQLException
-
setNetworkTimeout
- Specified by:
setNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
getNetworkTimeout
public int getNetworkTimeout()- Specified by:
getNetworkTimeout
in interfaceConnection
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
-
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
-
__test_host
for _TEST_ only- Returns:
- current host
-