Package org.apache.derby.impl.jdbc
Class Util
- java.lang.Object
-
- org.apache.derby.impl.jdbc.Util
-
public abstract class Util extends java.lang.Object
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 Modifier and Type Field Description private static int
logSeverityLevel
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
ASSERT(EmbedConnection conn, boolean mustBeTrue, java.lang.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 java.sql.SQLException
generateCsSQLException(java.lang.String error, java.lang.Object... args)
(package private) static java.sql.SQLException
generateCsSQLException(java.lang.String error, java.lang.Throwable t, java.lang.Object... args)
static java.sql.SQLException
generateCsSQLException(StandardException se)
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 java.sql.SQLException
javaException(java.lang.Throwable t)
static void
logAndThrowSQLException(java.sql.SQLException se)
Log SQLException to the error log if the severity exceeds the logSeverityLevel and then throw it.private static void
logError(java.lang.String errorMessage, java.lang.Throwable t)
static void
logSQLException(java.sql.SQLException se)
Log an SQLException to the error log or to the console if there is no error log available.(package private) static java.io.IOException
newIOException(java.lang.Throwable cause)
Create anIOException
that wraps anotherThrowable
.static java.sql.SQLException
noCurrentConnection()
static java.sql.SQLException
notImplemented()
static java.sql.SQLException
notImplemented(java.lang.String feature)
static java.sql.SQLException
policyNotReloaded(java.lang.Throwable t)
(package private) static java.sql.SQLException
seeNextException(java.lang.String messageId, java.sql.SQLException next, java.lang.Throwable cause, java.lang.Object... args)
Generate anSQLException
which points to anotherSQLException
nested within it withsetNextException()
.(package private) static java.sql.SQLException
setStreamFailure(java.io.IOException e)
static int[]
squashLongs(long[] longs)
Squash an array of longs into an array of ints(package private) static java.sql.SQLException
typeMisMatch(int targetSQLType)
static java.lang.String
typeName(int jdbcType)
-
-
-
Method Detail
-
logAndThrowSQLException
public static void logAndThrowSQLException(java.sql.SQLException se) throws java.sql.SQLException
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:
java.sql.SQLException
-
logSQLException
public static void logSQLException(java.sql.SQLException se)
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
private static void logError(java.lang.String errorMessage, java.lang.Throwable t)
-
ASSERT
public static void ASSERT(EmbedConnection conn, boolean mustBeTrue, java.lang.String msg) throws java.sql.SQLException
Mimic SanityManager.ASSERT in a JDBC-friendly way, and providing system cleanup for JDBC failures. We need the connection to do cleanup...- Throws:
java.sql.SQLException
- the exception
-
checkForSupportedDataType
public static void checkForSupportedDataType(int dataType) throws java.sql.SQLException
Checks whether a data type is supported and raises a SQLException if it isn't.- Throws:
java.sql.SQLException
-
checkSupportedRaiseStandard
public static void checkSupportedRaiseStandard(int dataType) throws StandardException
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
public static java.sql.SQLException generateCsSQLException(java.lang.String error, java.lang.Object... args)
-
generateCsSQLException
static java.sql.SQLException generateCsSQLException(java.lang.String error, java.lang.Throwable t, java.lang.Object... args)
-
generateCsSQLException
public static java.sql.SQLException generateCsSQLException(StandardException se)
-
noCurrentConnection
public static java.sql.SQLException noCurrentConnection()
-
seeNextException
static java.sql.SQLException seeNextException(java.lang.String messageId, java.sql.SQLException next, java.lang.Throwable cause, java.lang.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
public static java.sql.SQLException javaException(java.lang.Throwable t)
-
policyNotReloaded
public static java.sql.SQLException policyNotReloaded(java.lang.Throwable t)
-
notImplemented
public static java.sql.SQLException notImplemented()
-
notImplemented
public static java.sql.SQLException notImplemented(java.lang.String feature)
-
setStreamFailure
static java.sql.SQLException setStreamFailure(java.io.IOException e)
-
typeMisMatch
static java.sql.SQLException typeMisMatch(int targetSQLType)
-
squashLongs
public static int[] squashLongs(long[] longs)
Squash an array of longs into an array of ints
-
newIOException
static java.io.IOException newIOException(java.lang.Throwable cause)
Create anIOException
that wraps anotherThrowable
.- Parameters:
cause
- the underlying cause of the error- Returns:
- an
IOException
linked tocause
-
typeName
public static java.lang.String typeName(int jdbcType)
-
-