Package org.mariadb.jdbc.export
Class ExceptionFactory
- java.lang.Object
-
- org.mariadb.jdbc.export.ExceptionFactory
-
- Direct Known Subclasses:
ExceptionFactory.SqlExceptionFactory
public class ExceptionFactory extends java.lang.Object
Exception factory. This permit common error logging, with thread id, dump query, and specific dead-lock additional information
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ExceptionFactory.SqlExceptionFactory
Exception with SQL command
-
Field Summary
Fields Modifier and Type Field Description private Configuration
conf
private Connection
connection
private HostAddress
hostAddress
private static java.util.Set<java.lang.Integer>
LOCK_DEADLOCK_ERROR_CODES
private MariaDbPoolConnection
poolConnection
private java.sql.Statement
statement
private long
threadId
-
Constructor Summary
Constructors Modifier Constructor Description ExceptionFactory(Configuration conf, HostAddress hostAddress)
Connection Exception factory constructorprivate
ExceptionFactory(Connection connection, MariaDbPoolConnection poolConnection, Configuration conf, HostAddress hostAddress, long threadId, java.sql.Statement statement)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
buildMsgText(java.lang.String initialMessage, long threadId, Configuration conf, java.lang.String sql, int errorCode, Connection connection)
java.sql.SQLException
create(java.lang.String message)
Creation of an exceptionjava.sql.SQLException
create(java.lang.String message, java.lang.String sqlState)
Creation of an exceptionjava.sql.SQLException
create(java.lang.String message, java.lang.String sqlState, int errorCode)
Creation of an exceptionjava.sql.SQLException
create(java.lang.String message, java.lang.String sqlState, java.lang.Exception cause)
Creation of an exceptionjava.sql.BatchUpdateException
createBatchUpdate(java.util.List<Completion> res, int length, int[] responseMsg, java.sql.SQLException sqle)
Create a BatchUpdateException, filling successful updatesjava.sql.BatchUpdateException
createBatchUpdate(java.util.List<Completion> res, int length, java.sql.SQLException sqle)
Create a BatchUpdateException, filling successful updatesprivate java.sql.SQLException
createException(java.lang.String initialMessage, java.lang.String sqlState, int errorCode, java.lang.Exception cause)
java.lang.String
getSql()
get SQL commandjava.sql.SQLException
notSupported(java.lang.String message)
fast creation of SQLFeatureNotSupportedException exceptionExceptionFactory
of(java.sql.Statement statement)
Construct an Exception factory from this + adding current statementExceptionFactory
setConnection(Connection connection)
Set connection to factoryvoid
setConnection(ExceptionFactory oldExceptionFactory)
Set connectionExceptionFactory
setPoolConnection(MariaDbPoolConnection internalPoolConnection)
Set pool connection to factoryvoid
setThreadId(long threadId)
Set connection thread idExceptionFactory
withSql(java.lang.String sql)
Construct an Exception factory from this + adding current SQL
-
-
-
Field Detail
-
LOCK_DEADLOCK_ERROR_CODES
private static final java.util.Set<java.lang.Integer> LOCK_DEADLOCK_ERROR_CODES
-
conf
private final Configuration conf
-
hostAddress
private final HostAddress hostAddress
-
connection
private Connection connection
-
poolConnection
private MariaDbPoolConnection poolConnection
-
threadId
private long threadId
-
statement
private java.sql.Statement statement
-
-
Constructor Detail
-
ExceptionFactory
public ExceptionFactory(Configuration conf, HostAddress hostAddress)
Connection Exception factory constructor- Parameters:
conf
- configurationhostAddress
- current host
-
ExceptionFactory
private ExceptionFactory(Connection connection, MariaDbPoolConnection poolConnection, Configuration conf, HostAddress hostAddress, long threadId, java.sql.Statement statement)
-
-
Method Detail
-
buildMsgText
private static java.lang.String buildMsgText(java.lang.String initialMessage, long threadId, Configuration conf, java.lang.String sql, int errorCode, Connection connection)
-
setConnection
public void setConnection(ExceptionFactory oldExceptionFactory)
Set connection- Parameters:
oldExceptionFactory
- previous connection exception factory
-
setConnection
public ExceptionFactory setConnection(Connection connection)
Set connection to factory- Parameters:
connection
- connection- Returns:
- this
ExceptionFactory
-
setPoolConnection
public ExceptionFactory setPoolConnection(MariaDbPoolConnection internalPoolConnection)
Set pool connection to factory- Parameters:
internalPoolConnection
- internal pool connection- Returns:
- this
ExceptionFactory
-
setThreadId
public void setThreadId(long threadId)
Set connection thread id- Parameters:
threadId
- connection thread id
-
createBatchUpdate
public java.sql.BatchUpdateException createBatchUpdate(java.util.List<Completion> res, int length, java.sql.SQLException sqle)
Create a BatchUpdateException, filling successful updates- Parameters:
res
- completion listlength
- expected sizesqle
- exception- Returns:
- BatchUpdateException object
-
createBatchUpdate
public java.sql.BatchUpdateException createBatchUpdate(java.util.List<Completion> res, int length, int[] responseMsg, java.sql.SQLException sqle)
Create a BatchUpdateException, filling successful updates- Parameters:
res
- completion listlength
- expected lengthresponseMsg
- successful responsesqle
- exception- Returns:
- BatchUpdateException object
-
of
public ExceptionFactory of(java.sql.Statement statement)
Construct an Exception factory from this + adding current statement- Parameters:
statement
- current statement- Returns:
- new Exception factory
-
withSql
public ExceptionFactory withSql(java.lang.String sql)
Construct an Exception factory from this + adding current SQL- Parameters:
sql
- current sql command- Returns:
- new Exception factory
-
createException
private java.sql.SQLException createException(java.lang.String initialMessage, java.lang.String sqlState, int errorCode, java.lang.Exception cause)
-
notSupported
public java.sql.SQLException notSupported(java.lang.String message)
fast creation of SQLFeatureNotSupportedException exception- Parameters:
message
- error message- Returns:
- exception to be thrown
-
create
public java.sql.SQLException create(java.lang.String message)
Creation of an exception- Parameters:
message
- error message- Returns:
- exception to be thrown
-
create
public java.sql.SQLException create(java.lang.String message, java.lang.String sqlState)
Creation of an exception- Parameters:
message
- error messagesqlState
- sql state- Returns:
- exception to be thrown
-
create
public java.sql.SQLException create(java.lang.String message, java.lang.String sqlState, java.lang.Exception cause)
Creation of an exception- Parameters:
message
- error messagesqlState
- sql statecause
- initial exception- Returns:
- exception to be thrown
-
create
public java.sql.SQLException create(java.lang.String message, java.lang.String sqlState, int errorCode)
Creation of an exception- Parameters:
message
- error messagesqlState
- sql stateerrorCode
- error code- Returns:
- exception to be thrown
-
getSql
public java.lang.String getSql()
get SQL command- Returns:
- sql command
-
-