Top Description Methods
com.mysql.cj.jdbc.interceptors

public Interface ConnectionLifecycleInterceptor

Imports
java.sql.SQLException, .Savepoint, java.util.Properties, com.mysql.cj.MysqlConnection, com.mysql.cj.log.Log

Implementors of this interface can be installed via the "connectionLifecycleInterceptors" configuration property and receive events and alter behavior of "lifecycle" methods on our connection implementation. The driver will create one instance of a given interceptor per-connection.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Called when an application calls Connection.close(), before the driver processes its own internal logic for close.

public boolean

Returns:

"true" if the driver should perform its own internal logic for commit(), or "false" if not.
commit
()

Called when an application calls Connection.commit(), before the driver processes its own internal logic for commit().

public void
destroy()

Called by the driver when this extension should release any resources it is holding and cleanup internally before the connection is closed.

public ConnectionLifecycleInterceptor

Returns:

interceptor
init
(MysqlConnection
the connection for which this extension is being created
conn
,
Properties
configuration values as passed to the connection. Note that in order to support javax.sql.DataSources, configuration properties specific to an interceptor must be passed via setURL() on the DataSource. Extension properties are not exposed via accessor/mutator methods on DataSources.
props
,
Log
logger instance
log
)

Called once per connection that wants to use the extension The properties are the same ones passed in in the URL or arguments to Driver.connect() or DriverManager.getConnection().

public boolean

Returns:

"true" if the driver should perform its own internal logic for rollback(), or "false" if not.
rollback
()

Called when an application calls Connection.rollback(), before the driver processes its own internal logic for rollback().

public boolean

Returns:

"true" if the driver should perform its own internal logic for rollback(), or "false" if not.
rollback
(Savepoint
savepoint
s
)

Called when an application calls Connection.rollback(), before the driver processes its own internal logic for rollback().

public boolean

Returns:

"true" if the driver should perform its own internal logic for setAutoCommit(), or "false" if not.
setAutoCommit
(boolean
autocommit flag
flag
)

Called when an application calls Connection.setAutoCommit(), before the driver processes its own internal logic for setAutoCommit().

public boolean

Returns:

"true" if the driver should perform its own internal logic for setCatalog() or setSchema(), or "false" if not.
setDatabase
(String
database name
db
)

Called when an application calls Connection.setCatalog() or Connection.setSchema(), before the driver processes its own internal logic for these methods.

public boolean

Returns:

true if transaction is in progress
transactionBegun
()

Called when the driver has been told by the server that a transaction is now in progress (when one has not been currently in progress).

public boolean

Returns:

true if transaction is completed
transactionCompleted
()

Called when the driver has been told by the server that a transaction has completed, and no transaction is currently in progress.

Method Detail

closeback to summary
public void close() throws SQLException

Called when an application calls Connection.close(), before the driver processes its own internal logic for close.

Exceptions
SQLException:
if an error occurs
commitback to summary
public boolean commit() throws SQLException

Called when an application calls Connection.commit(), before the driver processes its own internal logic for commit(). Interceptors should return "true" if the driver should perform its own internal logic for commit(), or "false" if not.

Returns:boolean

"true" if the driver should perform its own internal logic for commit(), or "false" if not.

Exceptions
SQLException:
if an error occurs
destroyback to summary
public void destroy()

Called by the driver when this extension should release any resources it is holding and cleanup internally before the connection is closed.

initback to summary
public ConnectionLifecycleInterceptor init(MysqlConnection conn, Properties props, Log log)

Called once per connection that wants to use the extension The properties are the same ones passed in in the URL or arguments to Driver.connect() or DriverManager.getConnection().

Parameters
conn:MysqlConnection

the connection for which this extension is being created

props:Properties

configuration values as passed to the connection. Note that in order to support javax.sql.DataSources, configuration properties specific to an interceptor must be passed via setURL() on the DataSource. Extension properties are not exposed via accessor/mutator methods on DataSources.

log:Log

logger instance

Returns:ConnectionLifecycleInterceptor

interceptor

rollbackback to summary
public boolean rollback() throws SQLException

Called when an application calls Connection.rollback(), before the driver processes its own internal logic for rollback(). Interceptors should return "true" if the driver should perform its own internal logic for rollback(), or "false" if not.

Returns:boolean

"true" if the driver should perform its own internal logic for rollback(), or "false" if not.

Exceptions
SQLException:
if an error occurs
rollbackback to summary
public boolean rollback(Savepoint s) throws SQLException

Called when an application calls Connection.rollback(), before the driver processes its own internal logic for rollback(). Interceptors should return "true" if the driver should perform its own internal logic for rollback(), or "false" if not.

Parameters
s:Savepoint

savepoint

Returns:boolean

"true" if the driver should perform its own internal logic for rollback(), or "false" if not.

Exceptions
SQLException:
if an error occurs
setAutoCommitback to summary
public boolean setAutoCommit(boolean flag) throws SQLException

Called when an application calls Connection.setAutoCommit(), before the driver processes its own internal logic for setAutoCommit(). Interceptors should return "true" if the driver should perform its own internal logic for setAutoCommit(), or "false" if not.

Parameters
flag:boolean

autocommit flag

Returns:boolean

"true" if the driver should perform its own internal logic for setAutoCommit(), or "false" if not.

Exceptions
SQLException:
if an error occurs
setDatabaseback to summary
public boolean setDatabase(String db) throws SQLException

Called when an application calls Connection.setCatalog() or Connection.setSchema(), before the driver processes its own internal logic for these methods. Interceptors should return "true" if the driver should perform its own internal logic for setCatalog() or setSchema(), or "false" if not.

Parameters
db:String

database name

Returns:boolean

"true" if the driver should perform its own internal logic for setCatalog() or setSchema(), or "false" if not.

Exceptions
SQLException:
if an error occurs
transactionBegunback to summary
public boolean transactionBegun()

Called when the driver has been told by the server that a transaction is now in progress (when one has not been currently in progress).

Returns:boolean

true if transaction is in progress

transactionCompletedback to summary
public boolean transactionCompleted()

Called when the driver has been told by the server that a transaction has completed, and no transaction is currently in progress.

Returns:boolean

true if transaction is completed