Package org.apache.derby.impl.jdbc
Class Util
java.lang.Object
org.apache.derby.impl.jdbc.Util
This class understands the message protocol and looks up
SQLExceptions based on keys, so that the Local JDBC driver's
messages can be localized.
REMIND: May want to investigate putting some of this in the protocol
side, for the errors that any Derby JDBC driver might return.
The ASSERT mechanism is a wrapper of the basic services,
to ensure that failed asserts at this level will behave
well in a JDBC environment.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
ASSERT
(EmbedConnection conn, boolean mustBeTrue, String msg) Mimic SanityManager.ASSERT in a JDBC-friendly way, and providing system cleanup for JDBC failures.static void
checkForSupportedDataType
(int dataType) Checks whether a data type is supported and raises a SQLException if it isn't.static void
checkSupportedRaiseStandard
(int dataType) Checks whether a data type is supported and raises a StandardException if it isn't.static SQLException
generateCsSQLException
(String error, Object... args) (package private) static SQLException
generateCsSQLException
(String error, Throwable t, Object... args) static SQLException
private static boolean
isSupportedType
(int dataType) Returns false if a data type is not supported for:setObject(int, Object, int)
andsetObject(int, Object, int, int)
.static SQLException
static void
Log SQLException to the error log if the severity exceeds the logSeverityLevel and then throw it.private static void
static void
Log an SQLException to the error log or to the console if there is no error log available.(package private) static IOException
newIOException
(Throwable cause) Create anIOException
that wraps anotherThrowable
.static SQLException
static SQLException
static SQLException
notImplemented
(String feature) static SQLException
(package private) static SQLException
seeNextException
(String messageId, SQLException next, Throwable cause, Object... args) Generate anSQLException
which points to anotherSQLException
nested within it withsetNextException()
.(package private) static SQLException
static int[]
squashLongs
(long[] longs) Squash an array of longs into an array of ints(package private) static SQLException
typeMisMatch
(int targetSQLType) static String
typeName
(int jdbcType)
-
Field Details
-
logSeverityLevel
private static int logSeverityLevel
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
logAndThrowSQLException
Log SQLException to the error log if the severity exceeds the logSeverityLevel and then throw it. This method can be used for logging JDBC exceptions to derby.log DERBY-1191.- Parameters:
se
- SQLException to log and throw- Throws:
SQLException
-
logSQLException
Log an SQLException to the error log or to the console if there is no error log available. This method could perhaps be optimized to have a static shared ErrorStringBuilder and synchronize the method, but this works for now.- Parameters:
se
- SQLException to log
-
logError
-
ASSERT
Mimic SanityManager.ASSERT in a JDBC-friendly way, and providing system cleanup for JDBC failures. We need the connection to do cleanup...- Throws:
SQLException
- the exception
-
checkForSupportedDataType
Checks whether a data type is supported and raises a SQLException if it isn't.- Throws:
SQLException
-
checkSupportedRaiseStandard
Checks whether a data type is supported and raises a StandardException if it isn't.- Throws:
StandardException
-
isSupportedType
private static boolean isSupportedType(int dataType) Returns false if a data type is not supported for:setObject(int, Object, int)
andsetObject(int, Object, int, int)
.- Parameters:
dataType
- the data type to check
-
generateCsSQLException
-
generateCsSQLException
-
generateCsSQLException
-
noCurrentConnection
-
seeNextException
static SQLException seeNextException(String messageId, SQLException next, Throwable cause, Object... args) Generate anSQLException
which points to anotherSQLException
nested within it withsetNextException()
.- Parameters:
messageId
- message idnext
- the next SQLException, possibly nullcause
- the underlying exception, possibly nullargs
- the arguments to the message creation- Returns:
- an SQLException wrapping another SQLException
-
javaException
-
policyNotReloaded
-
notImplemented
-
notImplemented
-
setStreamFailure
-
typeMisMatch
-
squashLongs
public static int[] squashLongs(long[] longs) Squash an array of longs into an array of ints -
newIOException
Create anIOException
that wraps anotherThrowable
.- Parameters:
cause
- the underlying cause of the error- Returns:
- an
IOException
linked tocause
-
typeName
-