public class ConnectionImpl extends java.lang.Object implements JdbcConnection, Session.SessionEventListener, java.io.Serializable
A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is obtained with the getMetaData method.
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
ConnectionImpl.CompoundCacheKey
Used as a key for caching callable/prepared statements which (may) depend on current database.
|
private static class |
ConnectionImpl.NetworkTimeoutSetter |
| Modifier and Type | Field and Description |
|---|---|
private static java.sql.SQLPermission |
ABORT_PERM |
private int |
autoIncrementIncrement |
private RuntimeProperty<java.lang.Boolean> |
autoReconnect |
private RuntimeProperty<java.lang.Boolean> |
autoReconnectForPools |
private RuntimeProperty<java.lang.Boolean> |
cachePrepStmts |
private java.util.List<ConnectionLifecycleInterceptor> |
connectionLifecycleInterceptors |
private java.lang.String |
database
The database we're currently using.
|
private java.sql.DatabaseMetaData |
dbmd
Internal DBMD to use for various database-version specific features
|
protected static java.lang.String |
DEFAULT_LOGGER_CLASS
Default logger class name
|
private static int |
DEFAULT_RESULT_SET_CONCURRENCY |
private static int |
DEFAULT_RESULT_SET_TYPE |
private RuntimeProperty<java.lang.Boolean> |
disconnectOnExpiredPasswords |
private RuntimeProperty<java.lang.Boolean> |
emulateUnsupportedPstmts |
private ExceptionInterceptor |
exceptionInterceptor |
private boolean |
hasTriedSourceFlag |
private RuntimeProperty<java.lang.Boolean> |
ignoreNonTxTables |
private ClientInfoProvider |
infoProvider |
private boolean |
isInGlobalTx
Is this connection associated with a global tx?
|
private int |
isolationLevel
isolation level
|
private static java.util.Map<java.lang.String,java.lang.Integer> |
mapTransIsolationNameToValue
Map mysql transaction isolation level name to
java.sql.Connection.TRANSACTION_XXX
|
protected ResultSetFactory |
nullStatementResultSetFactory |
private java.util.concurrent.CopyOnWriteArrayList<JdbcStatement> |
openStatements
An array of currently open statements.
|
private HostInfo |
origHostInfo |
private java.lang.String |
origHostToConnectTo |
private int |
origPortToConnectTo |
private JdbcConnection |
parentProxy |
private LRUCache<ConnectionImpl.CompoundCacheKey,CallableStatement.CallableStatementParamInfo> |
parsedCallableStatementCache |
private java.lang.String |
password
The password we used
|
private RuntimeProperty<java.lang.Boolean> |
pedantic |
private RuntimeProperty<java.lang.Integer> |
prepStmtCacheSqlLimit |
private RuntimeProperty<java.lang.Boolean> |
processEscapeCodesForPrepStmts |
protected JdbcPropertySet |
propertySet |
protected java.util.Properties |
props
Properties for this connection specified by user
|
private CacheAdapter<java.lang.String,QueryInfo> |
queryInfoCache
A cache of SQL to parsed prepared statement parameters.
|
private java.util.List<QueryInterceptor> |
queryInterceptors |
private static java.util.Random |
random |
private boolean |
readOnly
Are we in read-only mode?
|
private RuntimeProperty<java.lang.Boolean> |
readOnlyPropagatesToServer |
private java.lang.reflect.InvocationHandler |
realProxy |
private RuntimeProperty<java.lang.Boolean> |
reconnectAtTxEnd |
protected LRUCache<java.lang.String,CachedResultSetMetaData> |
resultSetMetadataCache
Cache of ResultSet metadata
|
protected static java.util.Map<?,?> |
roundRobinStatsMap |
private static long |
serialVersionUID |
private LRUCache<ConnectionImpl.CompoundCacheKey,ServerPreparedStatement> |
serverSideStatementCache |
private LRUCache<java.lang.String,java.lang.Boolean> |
serverSideStatementCheckCache |
private NativeSession |
session |
private static java.sql.SQLPermission |
SET_NETWORK_TIMEOUT_PERM |
private JdbcConnection |
topProxy |
private java.util.Map<java.lang.String,java.lang.Class<?>> |
typeMap
The type map for UDTs (not implemented, but used by some third-party
vendors, most notably IBM WebSphere)
|
private RuntimeProperty<java.lang.Boolean> |
useLocalSessionState |
private RuntimeProperty<java.lang.Boolean> |
useLocalTransactionState |
private java.lang.String |
user
The user we're connected as
|
private RuntimeProperty<java.lang.Boolean> |
useServerPrepStmts |
private RuntimeProperty<java.lang.Boolean> |
useUsageAdvisor |
| Modifier | Constructor and Description |
|---|---|
protected |
ConnectionImpl()
'
For the delegate only
|
|
ConnectionImpl(HostInfo hostInfo)
Creates a connection to a MySQL Server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort(java.util.concurrent.Executor executor) |
void |
abortInternal()
Clobbers the physical network connection and marks this connection as closed.
|
private boolean |
canHandleAsServerPreparedStatement(java.lang.String sql) |
void |
changeUser(java.lang.String userName,
java.lang.String newPassword)
Changes the user on this connection by performing a re-authentication.
|
void |
checkClosed() |
private void |
checkTransactionIsolationLevel()
Set transaction isolation level to the value received from server if any.
|
void |
cleanup(java.lang.Throwable whyCleanedUp)
Destroys this connection and any underlying resources.
|
void |
clearHasTriedMaster()
Deprecated.
|
void |
clearWarnings() |
java.sql.PreparedStatement |
clientPrepareStatement(java.lang.String sql)
Prepares a statement on the client, using client-side emulation
(irregardless of the configuration property 'useServerPrepStmts')
with the same semantics as the java.sql.Connection.prepareStatement()
method with the same argument types.
|
java.sql.PreparedStatement |
clientPrepareStatement(java.lang.String sql,
int autoGenKeyIndex)
Prepares a statement on the client, using client-side emulation
(irregardless of the configuration property 'useServerPrepStmts')
with the same semantics as the java.sql.Connection.prepareStatement()
method with the same argument types.
|
java.sql.PreparedStatement |
clientPrepareStatement(java.lang.String sql,
int[] autoGenKeyIndexes)
Prepares a statement on the client, using client-side emulation
(irregardless of the configuration property 'useServerPrepStmts')
with the same semantics as the java.sql.Connection.prepareStatement()
method with the same argument types.
|
java.sql.PreparedStatement |
clientPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Prepares a statement on the client, using client-side emulation
(irregardless of the configuration property 'useServerPrepStmts')
with the same semantics as the java.sql.Connection.prepareStatement()
method with the same argument types.
|
java.sql.PreparedStatement |
clientPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
boolean processEscapeCodesIfNeeded) |
java.sql.PreparedStatement |
clientPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Prepares a statement on the client, using client-side emulation
(irregardless of the configuration property 'useServerPrepStmts')
with the same semantics as the java.sql.Connection.prepareStatement()
method with the same argument types.
|
java.sql.PreparedStatement |
clientPrepareStatement(java.lang.String sql,
java.lang.String[] autoGenKeyColNames)
Prepares a statement on the client, using client-side emulation
(irregardless of the configuration property 'useServerPrepStmts')
with the same semantics as the java.sql.Connection.prepareStatement()
method with the same argument types.
|
void |
close() |
private void |
closeAllOpenStatements()
Closes all currently open statements.
|
private void |
closeStatement(java.sql.Statement stmt) |
void |
commit() |
private void |
connectOneTryOnly(boolean isForReconnect) |
private void |
connectWithRetries(boolean isForReconnect) |
java.sql.Array |
createArrayOf(java.lang.String typeName,
java.lang.Object[] elements) |
java.sql.Blob |
createBlob() |
java.sql.Clob |
createClob() |
java.sql.NClob |
createNClob() |
void |
createNewIO(boolean isForReconnect)
Creates an IO channel to the server.
|
private void |
createPreparedStatementCaches() |
java.sql.SQLXML |
createSQLXML() |
java.sql.Statement |
createStatement() |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency) |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
java.sql.Struct |
createStruct(java.lang.String typeName,
java.lang.Object[] attributes) |
void |
decachePreparedStatement(JdbcPreparedStatement pstmt) |
JdbcConnection |
getActiveMySQLConnection() |
int |
getActiveStatementCount()
Returns the number of statements active on this connection, which
haven't been .close()d.
|
boolean |
getAutoCommit() |
int |
getAutoIncrementIncrement()
Returns the -session- value of 'auto_increment_increment' from the server if it exists,
or '1' if not.
|
CachedResultSetMetaData |
getCachedMetaData(java.lang.String sql)
Returns cached metadata (or null if not cached) for the given query, which must match _exactly_.
|
java.lang.String |
getCatalog() |
java.lang.String |
getCharacterSetMetadata() |
java.util.Properties |
getClientInfo() |
java.lang.String |
getClientInfo(java.lang.String name) |
ClientInfoProvider |
getClientInfoProviderImpl() |
java.lang.Object |
getConnectionMutex() |
java.lang.String |
getDatabase()
Retrieves this connection object's current database name.
|
ExceptionInterceptor |
getExceptionInterceptor() |
int |
getHoldability() |
java.lang.String |
getHost() |
java.lang.String |
getHostPortPair() |
long |
getId() |
long |
getIdleFor()
NOT JDBC-Compliant, but clients can use this method to determine how long
this connection has been idle.
|
static JdbcConnection |
getInstance(HostInfo hostInfo)
Creates a connection instance.
|
private int |
getLoginTimeout() |
java.sql.DatabaseMetaData |
getMetaData() |
private java.sql.DatabaseMetaData |
getMetaData(boolean checkClosed,
boolean checkForInfoSchema) |
java.sql.Statement |
getMetadataSafeStatement() |
java.sql.Statement |
getMetadataSafeStatement(int maxRows) |
JdbcConnection |
getMultiHostParentProxy() |
JdbcConnection |
getMultiHostSafeProxy() |
int |
getNetworkTimeout() |
protected static int |
getNextRoundRobinHostIndex(java.lang.String url,
java.util.List<?> hostList) |
java.util.Properties |
getProperties()
Returns the parsed and passed in properties for this connection.
|
JdbcPropertySet |
getPropertySet() |
private JdbcConnection |
getProxy() |
java.util.List<QueryInterceptor> |
getQueryInterceptorsInstances() |
java.lang.String |
getSchema() |
ServerSessionStateController |
getServerSessionStateController() |
ServerVersion |
getServerVersion() |
NativeSession |
getSession() |
int |
getSessionMaxRows()
Returns the sql select limit max-rows for this session.
|
java.lang.String |
getStatementComment()
Returns the comment that will be prepended to all statements
sent to the server.
|
int |
getTransactionIsolation() |
java.util.Map<java.lang.String,java.lang.Class<?>> |
getTypeMap() |
java.lang.String |
getURL() |
java.lang.String |
getUser() |
java.sql.SQLWarning |
getWarnings() |
private void |
handleAutoCommitDefaults()
Resets a default auto-commit value of 0 to 1, as required by JDBC specification.
|
void |
handleCleanup(java.lang.Throwable whyCleanedUp) |
void |
handleNormalClose() |
void |
handleReconnect() |
boolean |
hasSameProperties(JdbcConnection c)
Does this connection have the same properties as another?
|
boolean |
hasTriedMaster()
Deprecated.
|
private void |
initializePropsFromServer()
Sets varying properties that depend on server information.
|
void |
initializeResultsMetadataFromCache(java.lang.String sql,
CachedResultSetMetaData cachedMetaData,
ResultSetInternalMethods resultSet)
Caches CachedResultSetMetaData that has been placed in the cache using the given SQL as a key.
|
void |
initializeSafeQueryInterceptors() |
boolean |
isClosed() |
boolean |
isInGlobalTx()
Is this connection currently a participant in an XA transaction?
|
boolean |
isProxySet() |
boolean |
isReadOnly() |
boolean |
isReadOnly(boolean useSessionStatus)
Tests to see if the connection is in Read Only Mode.
|
boolean |
isSameResource(JdbcConnection otherConnection)
Does this connection have the same resource name as the given
connection (for XA)?
|
boolean |
isServerLocal()
Is the server this connection is connected to "local" (i.e.
|
boolean |
isSourceConnection()
Is this connection connected to the first host in the list if
there is a list of servers in the URL?
|
boolean |
isValid(int timeout) |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
boolean |
lowerCaseTableNames()
Is the server configured to use lower-case table names only?
|
java.lang.String |
nativeSQL(java.lang.String sql) |
void |
normalClose() |
private static boolean |
nullSafeCompare(java.lang.String s1,
java.lang.String s2) |
private CallableStatement |
parseCallableStatement(java.lang.String sql) |
void |
ping()
Detect if the connection is still good by sending a ping command
to the server.
|
void |
pingInternal(boolean checkForClosedConnection,
int timeoutMillis) |
java.sql.CallableStatement |
prepareCall(java.lang.String sql) |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency) |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGenKeyIndex) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] autoGenKeyIndexes) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] autoGenKeyColNames) |
void |
realClose(boolean calledExplicitly,
boolean issueRollback,
boolean skipLocalTeardown,
java.lang.Throwable reason)
Closes connection and frees resources.
|
void |
recachePreparedStatement(JdbcPreparedStatement pstmt) |
void |
registerStatement(JdbcStatement stmt)
Register a Statement instance as open.
|
void |
releaseSavepoint(java.sql.Savepoint arg0) |
void |
resetServerState()
Resets the server-side state of this connection.
|
void |
rollback() |
void |
rollback(java.sql.Savepoint savepoint) |
private void |
rollbackNoChecks() |
java.sql.PreparedStatement |
serverPrepareStatement(java.lang.String sql)
Prepares a statement on the server (irregardless of the
configuration property 'useServerPrepStmts') with the same semantics
as the java.sql.Connection.prepareStatement() method with the
same argument types.
|
java.sql.PreparedStatement |
serverPrepareStatement(java.lang.String sql,
int autoGenKeyIndex)
Prepares a statement on the server (irregardless of the
configuration property 'useServerPrepStmts') with the same semantics
as the java.sql.Connection.prepareStatement() method with the
same argument types.
|
java.sql.PreparedStatement |
serverPrepareStatement(java.lang.String sql,
int[] autoGenKeyIndexes)
Prepares a statement on the server (irregardless of the
configuration property 'useServerPrepStmts') with the same semantics
as the java.sql.Connection.prepareStatement() method with the
same argument types.
|
java.sql.PreparedStatement |
serverPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Prepares a statement on the server (irregardless of the
configuration property 'useServerPrepStmts') with the same semantics
as the java.sql.Connection.prepareStatement() method with the
same argument types.
|
java.sql.PreparedStatement |
serverPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Prepares a statement on the server (irregardless of the
configuration property 'useServerPrepStmts') with the same semantics
as the java.sql.Connection.prepareStatement() method with the
same argument types.
|
java.sql.PreparedStatement |
serverPrepareStatement(java.lang.String sql,
java.lang.String[] autoGenKeyColNames)
Prepares a statement on the server (irregardless of the
configuration property 'useServerPrepStmts') with the same semantics
as the java.sql.Connection.prepareStatement() method with the
same argument types.
|
void |
setAutoCommit(boolean autoCommitFlag) |
void |
setCatalog(java.lang.String catalog) |
void |
setClientInfo(java.util.Properties properties) |
void |
setClientInfo(java.lang.String name,
java.lang.String value) |
void |
setDatabase(java.lang.String db)
Set current database for this connection.
|
void |
setFailedOver(boolean flag) |
void |
setHoldability(int arg0) |
void |
setInGlobalTx(boolean flag)
Set the state of being in a global (XA) transaction.
|
void |
setNetworkTimeout(java.util.concurrent.Executor executor,
int milliseconds) |
void |
setProxy(JdbcConnection proxy) |
void |
setReadOnly(boolean readOnlyFlag) |
void |
setReadOnlyInternal(boolean readOnlyFlag) |
java.sql.Savepoint |
setSavepoint() |
private void |
setSavepoint(MysqlSavepoint savepoint) |
java.sql.Savepoint |
setSavepoint(java.lang.String name) |
void |
setSchema(java.lang.String schema) |
void |
setSessionMaxRows(int max)
Sets the sql select limit max-rows for this session if different from current.
|
void |
setStatementComment(java.lang.String comment)
Sets the comment that will be prepended to all statements
sent to the server.
|
void |
setTransactionIsolation(int level) |
void |
setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> map) |
private void |
setupServerForTruncationChecks() |
void |
shutdownServer()
Used by MiniAdmin to shutdown a MySQL server
|
boolean |
storesLowerCaseTableName() |
void |
throwConnectionClosedException() |
void |
transactionBegun() |
void |
transactionCompleted() |
void |
unregisterStatement(JdbcStatement stmt)
Remove the given statement from the list of open statements
|
void |
unSafeQueryInterceptors() |
<T> T |
unwrap(java.lang.Class<T> iface) |
boolean |
versionMeetsMinimum(int major,
int minor,
int subminor) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisMasterConnectionprivate static final long serialVersionUID
private static final java.sql.SQLPermission SET_NETWORK_TIMEOUT_PERM
private static final java.sql.SQLPermission ABORT_PERM
private JdbcConnection parentProxy
private JdbcConnection topProxy
private java.lang.reflect.InvocationHandler realProxy
protected static final java.lang.String DEFAULT_LOGGER_CLASS
private static java.util.Map<java.lang.String,java.lang.Integer> mapTransIsolationNameToValue
protected static java.util.Map<?,?> roundRobinStatsMap
private java.util.List<ConnectionLifecycleInterceptor> connectionLifecycleInterceptors
private static final int DEFAULT_RESULT_SET_TYPE
private static final int DEFAULT_RESULT_SET_CONCURRENCY
private static final java.util.Random random
private CacheAdapter<java.lang.String,QueryInfo> queryInfoCache
private java.lang.String database
private java.sql.DatabaseMetaData dbmd
private NativeSession session
private boolean isInGlobalTx
private int isolationLevel
private final java.util.concurrent.CopyOnWriteArrayList<JdbcStatement> openStatements
private LRUCache<ConnectionImpl.CompoundCacheKey,CallableStatement.CallableStatementParamInfo> parsedCallableStatementCache
private java.lang.String password
protected java.util.Properties props
private boolean readOnly
protected LRUCache<java.lang.String,CachedResultSetMetaData> resultSetMetadataCache
private java.util.Map<java.lang.String,java.lang.Class<?>> typeMap
private java.lang.String user
private LRUCache<java.lang.String,java.lang.Boolean> serverSideStatementCheckCache
private LRUCache<ConnectionImpl.CompoundCacheKey,ServerPreparedStatement> serverSideStatementCache
private HostInfo origHostInfo
private java.lang.String origHostToConnectTo
private int origPortToConnectTo
private boolean hasTriedSourceFlag
private java.util.List<QueryInterceptor> queryInterceptors
protected JdbcPropertySet propertySet
private RuntimeProperty<java.lang.Boolean> autoReconnectForPools
private RuntimeProperty<java.lang.Boolean> cachePrepStmts
private RuntimeProperty<java.lang.Boolean> autoReconnect
private RuntimeProperty<java.lang.Boolean> useUsageAdvisor
private RuntimeProperty<java.lang.Boolean> reconnectAtTxEnd
private RuntimeProperty<java.lang.Boolean> emulateUnsupportedPstmts
private RuntimeProperty<java.lang.Boolean> ignoreNonTxTables
private RuntimeProperty<java.lang.Boolean> pedantic
private RuntimeProperty<java.lang.Integer> prepStmtCacheSqlLimit
private RuntimeProperty<java.lang.Boolean> useLocalSessionState
private RuntimeProperty<java.lang.Boolean> useServerPrepStmts
private RuntimeProperty<java.lang.Boolean> processEscapeCodesForPrepStmts
private RuntimeProperty<java.lang.Boolean> useLocalTransactionState
private RuntimeProperty<java.lang.Boolean> disconnectOnExpiredPasswords
private RuntimeProperty<java.lang.Boolean> readOnlyPropagatesToServer
protected ResultSetFactory nullStatementResultSetFactory
private int autoIncrementIncrement
private ExceptionInterceptor exceptionInterceptor
private ClientInfoProvider infoProvider
protected ConnectionImpl()
public ConnectionImpl(HostInfo hostInfo) throws java.sql.SQLException
hostInfo - the HostInfo instance that contains the host, user and connections attributes for this connectionjava.sql.SQLException - if a database access error occurspublic java.lang.String getHost()
getHost in interface JdbcConnectionpublic boolean isProxySet()
isProxySet in interface JdbcConnectionpublic void setProxy(JdbcConnection proxy)
setProxy in interface JdbcConnectionprivate JdbcConnection getProxy()
public JdbcConnection getMultiHostSafeProxy()
getMultiHostSafeProxy in interface JdbcConnectionpublic JdbcConnection getMultiHostParentProxy()
getMultiHostParentProxy in interface JdbcConnectionpublic JdbcConnection getActiveMySQLConnection()
getActiveMySQLConnection in interface JdbcConnectionpublic java.lang.Object getConnectionMutex()
getConnectionMutex in interface MysqlConnectionpublic static JdbcConnection getInstance(HostInfo hostInfo) throws java.sql.SQLException
hostInfo - HostInfo instanceConnectionImpl instancejava.sql.SQLException - if a database access error occursprotected static int getNextRoundRobinHostIndex(java.lang.String url,
java.util.List<?> hostList)
url - connection URLhostList - hosts listprivate static boolean nullSafeCompare(java.lang.String s1,
java.lang.String s2)
public JdbcPropertySet getPropertySet()
getPropertySet in interface JdbcConnectiongetPropertySet in interface MysqlConnectionpublic void unSafeQueryInterceptors()
throws java.sql.SQLException
unSafeQueryInterceptors in interface JdbcConnectionjava.sql.SQLExceptionpublic void initializeSafeQueryInterceptors()
throws java.sql.SQLException
initializeSafeQueryInterceptors in interface JdbcConnectionjava.sql.SQLExceptionpublic java.util.List<QueryInterceptor> getQueryInterceptorsInstances()
getQueryInterceptorsInstances in interface JdbcConnectionprivate boolean canHandleAsServerPreparedStatement(java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void changeUser(java.lang.String userName,
java.lang.String newPassword)
throws java.sql.SQLException
JdbcConnectionchangeUser in interface JdbcConnectionuserName - the username to authenticate withnewPassword - the password to authenticate withjava.sql.SQLException - if authentication fails, or some other error occurs while
performing the command.public void checkClosed()
checkClosed in interface MysqlConnectionpublic void throwConnectionClosedException()
throws java.sql.SQLException
throwConnectionClosedException in interface JdbcConnectionjava.sql.SQLExceptionprivate void checkTransactionIsolationLevel()
public void abortInternal()
throws java.sql.SQLException
JdbcConnectionabortInternal in interface JdbcConnectionjava.sql.SQLException - if an error occurspublic void cleanup(java.lang.Throwable whyCleanedUp)
MysqlConnectioncleanup in interface MysqlConnectionwhyCleanedUp - exception caused the connection clean up@Deprecated public void clearHasTriedMaster()
clearHasTriedMaster in interface JdbcConnectionpublic void clearWarnings()
throws java.sql.SQLException
clearWarnings in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql)
throws java.sql.SQLException
JdbcConnectionclientPrepareStatement in interface JdbcConnectionsql - statementjava.sql.SQLException - if an error occursConnection.prepareStatement(String)public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql,
int autoGenKeyIndex)
throws java.sql.SQLException
JdbcConnectionclientPrepareStatement in interface JdbcConnectionsql - statementautoGenKeyIndex - autoGenKeyIndexjava.sql.SQLException - if an error occursConnection.prepareStatement(String, int)public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
JdbcConnectionclientPrepareStatement in interface JdbcConnectionsql - statementresultSetType - resultSetTyperesultSetConcurrency - resultSetConcurrencyjava.sql.SQLException - if an error occursConnection.prepareStatement(String, int, int)public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
boolean processEscapeCodesIfNeeded)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql,
int[] autoGenKeyIndexes)
throws java.sql.SQLException
JdbcConnectionclientPrepareStatement in interface JdbcConnectionsql - statementautoGenKeyIndexes - autoGenKeyIndexesjava.sql.SQLException - if an error occursConnection.prepareStatement(String, int[])public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql,
java.lang.String[] autoGenKeyColNames)
throws java.sql.SQLException
JdbcConnectionclientPrepareStatement in interface JdbcConnectionsql - statementautoGenKeyColNames - autoGenKeyColNamesjava.sql.SQLException - if an error occursConnection.prepareStatement(String, String[])public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
JdbcConnectionclientPrepareStatement in interface JdbcConnectionsql - statementresultSetType - resultSetTyperesultSetConcurrency - resultSetConcurrencyresultSetHoldability - resultSetHoldabilityjava.sql.SQLException - if an error occursConnection.prepareStatement(String, int, int, int)public void close()
throws java.sql.SQLException
close in interface java.lang.AutoCloseableclose in interface java.sql.Connectionjava.sql.SQLExceptionpublic void normalClose()
normalClose in interface MysqlConnectionprivate void closeAllOpenStatements()
throws java.sql.SQLException
java.sql.SQLException - if a database access error occursprivate void closeStatement(java.sql.Statement stmt)
public void commit()
throws java.sql.SQLException
commit in interface java.sql.Connectionjava.sql.SQLExceptionpublic void createNewIO(boolean isForReconnect)
MysqlConnectioncreateNewIO in interface MysqlConnectionisForReconnect - is this request for a re-connectprivate void connectWithRetries(boolean isForReconnect)
throws java.sql.SQLException
java.sql.SQLExceptionprivate void connectOneTryOnly(boolean isForReconnect)
throws java.sql.SQLException
java.sql.SQLExceptionprivate int getLoginTimeout()
private void createPreparedStatementCaches()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.Statement createStatement()
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic int getActiveStatementCount()
JdbcConnectiongetActiveStatementCount in interface JdbcConnectionpublic boolean getAutoCommit()
throws java.sql.SQLException
getAutoCommit in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String getCatalog()
throws java.sql.SQLException
getCatalog in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String getCharacterSetMetadata()
getCharacterSetMetadata in interface JdbcConnectionpublic int getHoldability()
throws java.sql.SQLException
getHoldability in interface java.sql.Connectionjava.sql.SQLExceptionpublic long getId()
getId in interface MysqlConnectionpublic long getIdleFor()
getIdleFor in interface JdbcConnectionpublic java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
getMetaData in interface java.sql.Connectionjava.sql.SQLExceptionprivate java.sql.DatabaseMetaData getMetaData(boolean checkClosed,
boolean checkForInfoSchema)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.Statement getMetadataSafeStatement()
throws java.sql.SQLException
getMetadataSafeStatement in interface JdbcConnectionjava.sql.SQLExceptionpublic java.sql.Statement getMetadataSafeStatement(int maxRows)
throws java.sql.SQLException
java.sql.SQLExceptionpublic ServerVersion getServerVersion()
getServerVersion in interface JdbcConnectionpublic int getTransactionIsolation()
throws java.sql.SQLException
getTransactionIsolation in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap()
throws java.sql.SQLException
getTypeMap in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String getURL()
getURL in interface MysqlConnectionpublic java.lang.String getUser()
getUser in interface MysqlConnectionpublic java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
getWarnings in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean hasSameProperties(JdbcConnection c)
JdbcConnectionhasSameProperties in interface JdbcConnectionc - connectionpublic java.util.Properties getProperties()
MysqlConnectiongetProperties in interface MysqlConnectionProperties@Deprecated public boolean hasTriedMaster()
JdbcConnectionhasTriedMaster in interface JdbcConnectionprivate void initializePropsFromServer()
throws java.sql.SQLException
java.sql.SQLException - if a database access error occursprivate void handleAutoCommitDefaults()
throws java.sql.SQLException
java.sql.SQLException - if a database access error occurspublic boolean isClosed()
isClosed in interface java.sql.Connectionpublic boolean isInGlobalTx()
JdbcConnectionisInGlobalTx in interface JdbcConnectionpublic boolean isSourceConnection()
JdbcConnectionisSourceConnection in interface JdbcConnectionpublic boolean isReadOnly()
throws java.sql.SQLException
isReadOnly in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean isReadOnly(boolean useSessionStatus)
throws java.sql.SQLException
JdbcConnectionisReadOnly in interface JdbcConnectionuseSessionStatus - in some cases, for example when restoring connection with autoReconnect=true,
we can rely only on saved readOnly state, so use useSessionStatus=false in that casejava.sql.SQLException - if a database access error occurspublic boolean isSameResource(JdbcConnection otherConnection)
JdbcConnectionisSameResource in interface JdbcConnectionotherConnection - connectionpublic int getAutoIncrementIncrement()
JdbcConnectiongetAutoIncrementIncrement in interface JdbcConnectionpublic boolean lowerCaseTableNames()
JdbcConnectionlowerCaseTableNames in interface JdbcConnectionpublic java.lang.String nativeSQL(java.lang.String sql)
throws java.sql.SQLException
nativeSQL in interface java.sql.Connectionjava.sql.SQLExceptionprivate CallableStatement parseCallableStatement(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLExceptionpublic void ping()
throws java.sql.SQLException
JdbcConnectionping in interface JdbcConnectionjava.sql.SQLException - if the ping failspublic void pingInternal(boolean checkForClosedConnection,
int timeoutMillis)
throws java.sql.SQLException
pingInternal in interface JdbcConnectionjava.sql.SQLExceptionpublic java.sql.CallableStatement prepareCall(java.lang.String sql)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int autoGenKeyIndex)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int[] autoGenKeyIndexes)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
java.lang.String[] autoGenKeyColNames)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic void realClose(boolean calledExplicitly,
boolean issueRollback,
boolean skipLocalTeardown,
java.lang.Throwable reason)
throws java.sql.SQLException
JdbcConnectionrealClose in interface JdbcConnectioncalledExplicitly - is this being called from close()issueRollback - should a rollback() be issued?skipLocalTeardown - if true, driver tries to close connection normally, performing rollbacks,
closing open statements etc; otherwise the force close is performedreason - the exception caused this method calljava.sql.SQLException - if an error occurspublic void recachePreparedStatement(JdbcPreparedStatement pstmt) throws java.sql.SQLException
recachePreparedStatement in interface JdbcConnectionjava.sql.SQLExceptionpublic void decachePreparedStatement(JdbcPreparedStatement pstmt) throws java.sql.SQLException
decachePreparedStatement in interface JdbcConnectionjava.sql.SQLExceptionpublic void registerStatement(JdbcStatement stmt)
JdbcConnectionregisterStatement in interface JdbcConnectionstmt - the Statement instance to removepublic void releaseSavepoint(java.sql.Savepoint arg0)
throws java.sql.SQLException
releaseSavepoint in interface java.sql.Connectionjava.sql.SQLExceptionpublic void resetServerState()
throws java.sql.SQLException
JdbcConnectionresetServerState in interface JdbcConnectionjava.sql.SQLException - if the operation fails while resetting server state.public void rollback()
throws java.sql.SQLException
rollback in interface java.sql.Connectionjava.sql.SQLExceptionpublic void rollback(java.sql.Savepoint savepoint)
throws java.sql.SQLException
rollback in interface java.sql.Connectionjava.sql.SQLExceptionprivate void rollbackNoChecks()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql)
throws java.sql.SQLException
JdbcConnectionserverPrepareStatement in interface JdbcConnectionsql - statementjava.sql.SQLException - if an error occursConnection.prepareStatement(String)public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql,
int autoGenKeyIndex)
throws java.sql.SQLException
JdbcConnectionserverPrepareStatement in interface JdbcConnectionsql - statementautoGenKeyIndex - autoGenKeyIndexjava.sql.SQLException - if an error occursConnection.prepareStatement(String, int)public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
JdbcConnectionserverPrepareStatement in interface JdbcConnectionsql - statementresultSetType - resultSetTyperesultSetConcurrency - resultSetConcurrencyjava.sql.SQLException - if an error occursConnection.prepareStatement(String, int, int)public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
JdbcConnectionserverPrepareStatement in interface JdbcConnectionsql - statementresultSetType - resultSetTyperesultSetConcurrency - resultSetConcurrencyresultSetHoldability - resultSetHoldabilityjava.sql.SQLException - if an error occursConnection.prepareStatement(String, int, int, int)public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql,
int[] autoGenKeyIndexes)
throws java.sql.SQLException
JdbcConnectionserverPrepareStatement in interface JdbcConnectionsql - statementautoGenKeyIndexes - autoGenKeyIndexesjava.sql.SQLException - if an error occursConnection.prepareStatement(String, int[])public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql,
java.lang.String[] autoGenKeyColNames)
throws java.sql.SQLException
JdbcConnectionserverPrepareStatement in interface JdbcConnectionsql - statementautoGenKeyColNames - autoGenKeyColNamesjava.sql.SQLException - if an error occursConnection.prepareStatement(String, String[])public void setAutoCommit(boolean autoCommitFlag)
throws java.sql.SQLException
setAutoCommit in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setCatalog(java.lang.String catalog)
throws java.sql.SQLException
setCatalog in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setDatabase(java.lang.String db)
throws java.sql.SQLException
JdbcConnectionsetDatabase in interface JdbcConnectiondb - the database for this connection to usejava.sql.SQLException - if a database access error occurspublic java.lang.String getDatabase()
throws java.sql.SQLException
JdbcConnectiongetDatabase in interface JdbcConnectionjava.sql.SQLException - if an error occurspublic void setFailedOver(boolean flag)
setFailedOver in interface JdbcConnectionflag - The failedOver flag to set.public void setHoldability(int arg0)
throws java.sql.SQLException
setHoldability in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setInGlobalTx(boolean flag)
JdbcConnectionsetInGlobalTx in interface JdbcConnectionflag - the state flagpublic void setReadOnly(boolean readOnlyFlag)
throws java.sql.SQLException
setReadOnly in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setReadOnlyInternal(boolean readOnlyFlag)
throws java.sql.SQLException
setReadOnlyInternal in interface JdbcConnectionjava.sql.SQLExceptionpublic java.sql.Savepoint setSavepoint()
throws java.sql.SQLException
setSavepoint in interface java.sql.Connectionjava.sql.SQLExceptionprivate void setSavepoint(MysqlSavepoint savepoint) throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.Savepoint setSavepoint(java.lang.String name)
throws java.sql.SQLException
setSavepoint in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setTransactionIsolation(int level)
throws java.sql.SQLException
setTransactionIsolation in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
setTypeMap in interface java.sql.Connectionjava.sql.SQLExceptionprivate void setupServerForTruncationChecks()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void shutdownServer()
throws java.sql.SQLException
JdbcConnectionshutdownServer in interface JdbcConnectionjava.sql.SQLException - if the command can not be issued.public void unregisterStatement(JdbcStatement stmt)
JdbcConnectionunregisterStatement in interface JdbcConnectionstmt - the Statement instance to removepublic boolean versionMeetsMinimum(int major,
int minor,
int subminor)
public CachedResultSetMetaData getCachedMetaData(java.lang.String sql)
JdbcConnectiongetCachedMetaData in interface JdbcConnectionsql - the query that is the key to the cachepublic void initializeResultsMetadataFromCache(java.lang.String sql,
CachedResultSetMetaData cachedMetaData,
ResultSetInternalMethods resultSet)
throws java.sql.SQLException
JdbcConnectioninitializeResultsMetadataFromCache in interface JdbcConnectionsql - the query that the metadata pertains too.cachedMetaData - metadata (if it exists) to populate the cache.resultSet - the result set to retreive metadata from, or apply to.java.sql.SQLException - if an error occurspublic java.lang.String getStatementComment()
JdbcConnectiongetStatementComment in interface JdbcConnectionpublic void setStatementComment(java.lang.String comment)
JdbcConnectionsetStatementComment in interface JdbcConnectioncomment - the comment that will be prepended to all statements
sent to the server.public void transactionBegun()
transactionBegun in interface TransactionEventHandlerpublic void transactionCompleted()
transactionCompleted in interface TransactionEventHandlerpublic boolean storesLowerCaseTableName()
storesLowerCaseTableName in interface JdbcConnectionpublic ExceptionInterceptor getExceptionInterceptor()
getExceptionInterceptor in interface MysqlConnectionpublic boolean isServerLocal()
throws java.sql.SQLException
JdbcConnectionisServerLocal in interface JdbcConnectionjava.sql.SQLException - if an error occurspublic int getSessionMaxRows()
JdbcConnectiongetSessionMaxRows in interface JdbcConnectionpublic void setSessionMaxRows(int max)
throws java.sql.SQLException
JdbcConnectionsetSessionMaxRows in interface JdbcConnectionmax - the new max-rows value to set.java.sql.SQLException - if a database error occurs issuing the statement that sets the limit.public void setSchema(java.lang.String schema)
throws java.sql.SQLException
setSchema in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String getSchema()
throws java.sql.SQLException
getSchema in interface java.sql.Connectionjava.sql.SQLExceptionpublic void abort(java.util.concurrent.Executor executor)
throws java.sql.SQLException
abort in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setNetworkTimeout(java.util.concurrent.Executor executor,
int milliseconds)
throws java.sql.SQLException
setNetworkTimeout in interface java.sql.Connectionjava.sql.SQLExceptionpublic int getNetworkTimeout()
throws java.sql.SQLException
getNetworkTimeout in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Clob createClob()
createClob in interface java.sql.Connectionpublic java.sql.Blob createBlob()
createBlob in interface java.sql.Connectionpublic java.sql.NClob createNClob()
createNClob in interface java.sql.Connectionpublic java.sql.SQLXML createSQLXML()
throws java.sql.SQLException
createSQLXML in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean isValid(int timeout)
throws java.sql.SQLException
isValid in interface java.sql.Connectionjava.sql.SQLExceptionpublic ClientInfoProvider getClientInfoProviderImpl() throws java.sql.SQLException
getClientInfoProviderImpl in interface JdbcConnectionjava.sql.SQLExceptionpublic void setClientInfo(java.lang.String name,
java.lang.String value)
throws java.sql.SQLClientInfoException
setClientInfo in interface java.sql.Connectionjava.sql.SQLClientInfoExceptionpublic void setClientInfo(java.util.Properties properties)
throws java.sql.SQLClientInfoException
setClientInfo in interface java.sql.Connectionjava.sql.SQLClientInfoExceptionpublic java.lang.String getClientInfo(java.lang.String name)
throws java.sql.SQLException
getClientInfo in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.util.Properties getClientInfo()
throws java.sql.SQLException
getClientInfo in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Array createArrayOf(java.lang.String typeName,
java.lang.Object[] elements)
throws java.sql.SQLException
createArrayOf in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Struct createStruct(java.lang.String typeName,
java.lang.Object[] attributes)
throws java.sql.SQLException
createStruct in interface java.sql.Connectionjava.sql.SQLExceptionpublic <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperjava.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
isWrapperFor in interface java.sql.Wrapperjava.sql.SQLExceptionpublic NativeSession getSession()
getSession in interface MysqlConnectionpublic java.lang.String getHostPortPair()
getHostPortPair in interface JdbcConnectionpublic void handleNormalClose()
handleNormalClose in interface Session.SessionEventListenerpublic void handleReconnect()
handleReconnect in interface Session.SessionEventListenerpublic void handleCleanup(java.lang.Throwable whyCleanedUp)
handleCleanup in interface Session.SessionEventListenerpublic ServerSessionStateController getServerSessionStateController()
getServerSessionStateController in interface MysqlConnection