Top Description Fields Constructors Methods
org.apache.derby.impl.jdbc

public abstract Class Util

extends Object
Class Inheritance
Imports
java.io.IOException, java.sql.SQLException, .Types, org.apache.derby.shared.common.error.ErrorStringBuilder, .ExceptionSeverity, .StandardException, .ExceptionFactory, org.apache.derby.shared.common.reference.JDBC40Translation, .MessageId, .Property, .SQLState, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.services.io.StoredFormatIds, org.apache.derby.iapi.services.monitor.Monitor, org.apache.derby.iapi.services.property.PropertyUtil, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.stream.HeaderPrintWriter, org.apache.derby.iapi.types.TypeId

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

Modifier and TypeField and Description
private static int

Constructor Summary

AccessConstructor and Description
public
Util()

Method Summary

Modifier and TypeMethod and Description
public static void
ASSERT(EmbedConnection conn, boolean mustBeTrue, String msg)

Mimic SanityManager.ASSERT in a JDBC-friendly way, and providing system cleanup for JDBC failures.

public static void
checkForSupportedDataType(int dataType)

Checks whether a data type is supported and raises a SQLException if it isn't.

public static void
checkSupportedRaiseStandard(int dataType)

Checks whether a data type is supported and raises a StandardException if it isn't.

public static SQLException
pack-priv static SQLException
public static SQLException
private static boolean
isSupportedType(int
the data type to check
dataType
)

Returns false if a data type is not supported for: setObject(int, Object, int) and setObject(int, Object, int, int).

public static SQLException
public static void
logAndThrowSQLException(SQLException
SQLException to log and throw
se
)

Log SQLException to the error log if the severity exceeds the logSeverityLevel and then throw it.

private static void
logError(String errorMessage, Throwable t)

public static void
logSQLException(SQLException
SQLException to log
se
)

Log an SQLException to the error log or to the console if there is no error log available.

pack-priv static IOException

Returns:

an IOException linked to cause
newIOException
(Throwable
the underlying cause of the error
cause
)

Create an IOException that wraps another Throwable.

public static SQLException
public static SQLException
public static SQLException
pack-priv static SQLException

Returns:

an SQLException wrapping another SQLException
seeNextException
(String
message id
messageId
,
SQLException
the next SQLException, possibly null
next
,
Throwable
the underlying exception, possibly null
cause
,
Object...
the arguments to the message creation
args
)

Generate an SQLException which points to another SQLException nested within it with setNextException().

pack-priv static SQLException
public static int[]
squashLongs(long[] longs)

Squash an array of longs into an array of ints

pack-priv static SQLException
typeMisMatch(int targetSQLType)

public static String
typeName(int jdbcType)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

logSeverityLevelback to summary
private static int logSeverityLevel

Constructor Detail

Utilback to summary
public Util()

Method Detail

ASSERTback to summary
public static void ASSERT(EmbedConnection conn, boolean mustBeTrue, String msg) throws SQLException

Mimic SanityManager.ASSERT in a JDBC-friendly way, and providing system cleanup for JDBC failures. We need the connection to do cleanup...

Exceptions
SQLException:
the exception
checkForSupportedDataTypeback to summary
public static void checkForSupportedDataType(int dataType) throws SQLException

Checks whether a data type is supported and raises a SQLException if it isn't.

checkSupportedRaiseStandardback to summary
public static void checkSupportedRaiseStandard(int dataType) throws StandardException

Checks whether a data type is supported and raises a StandardException if it isn't.

generateCsSQLExceptionback to summary
public static SQLException generateCsSQLException(String error, Object... args)
generateCsSQLExceptionback to summary
pack-priv static SQLException generateCsSQLException(String error, Throwable t, Object... args)
generateCsSQLExceptionback to summary
public static SQLException generateCsSQLException(StandardException se)
isSupportedTypeback to summary
private static boolean isSupportedType(int dataType)

Returns false if a data type is not supported for: setObject(int, Object, int) and setObject(int, Object, int, int).

Parameters
dataType:int

the data type to check

javaExceptionback to summary
public static SQLException javaException(Throwable t)
logAndThrowSQLExceptionback to summary
public static void logAndThrowSQLException(SQLException se) throws 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

SQLException to log and throw

logErrorback to summary
private static void logError(String errorMessage, Throwable t)
logSQLExceptionback to summary
public static void logSQLException(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

SQLException to log

newIOExceptionback to summary
pack-priv static IOException newIOException(Throwable cause)

Create an IOException that wraps another Throwable.

Parameters
cause:Throwable

the underlying cause of the error

Returns:IOException

an IOException linked to cause

noCurrentConnectionback to summary
public static SQLException noCurrentConnection()
notImplementedback to summary
public static SQLException notImplemented()
notImplementedback to summary
public static SQLException notImplemented(String feature)
seeNextExceptionback to summary
pack-priv static SQLException seeNextException(String messageId, SQLException next, Throwable cause, Object... args)

Generate an SQLException which points to another SQLException nested within it with setNextException().

Parameters
messageId:String

message id

next:SQLException

the next SQLException, possibly null

cause:Throwable

the underlying exception, possibly null

args:Object[]

the arguments to the message creation

Returns:SQLException

an SQLException wrapping another SQLException

setStreamFailureback to summary
pack-priv static SQLException setStreamFailure(IOException e)
squashLongsback to summary
public static int[] squashLongs(long[] longs)

Squash an array of longs into an array of ints

typeMisMatchback to summary
pack-priv static SQLException typeMisMatch(int targetSQLType)
typeNameback to summary
public static String typeName(int jdbcType)