public interface Rebindable extends ConnectionBoundObject
Connection. Used by read/write splitting to reroute a plain
Statement whose SQL is only known at execute time: because the target statement is bound
to the connection that created it, the wrapper must re-create it on the routed connection.
A handle to the invoking wrapper is published on the per-call
PluginCallContext so a plugin (which only receives the raw target statement as
methodInvokeOn) can trigger the rebind.
| Modifier and Type | Method and Description |
|---|---|
default boolean |
canRebind()
Whether this statement can currently be rebound to a different connection.
|
java.sql.Connection |
getBoundConnection()
The connection the current target statement is bound to.
|
void |
rebind(java.sql.Connection newConnection)
Re-creates the underlying target statement on
newConnection, transferring its
configuration, and closes the previous target. |
getCreatedOnConnection, setCreatedOnConnectionjava.sql.Connection getBoundConnection()
throws java.sql.SQLException
java.sql.SQLExceptiondefault boolean canRebind()
true
for a plain Statement; a PreparedStatement/CallableStatement returns
false when it cannot be re-created (e.g. a one-shot stream/reader parameter was bound,
a batch is pending, or rebinding was not enabled for it).true if rebind(Connection) can be appliedvoid rebind(java.sql.Connection newConnection)
throws java.sql.SQLException
newConnection, transferring its
configuration, and closes the previous target. After this call, subsequent execution runs
against the new target statement.newConnection - the underlying (target) connection to rebind tojava.sql.SQLException