org.apache.derby.impl.jdbc
Class Util

java.lang.Object
  extended by 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
private static SQLExceptionFactory exceptionFactory
           
private static int logSeverityLevel
           
 
Constructor Summary
Util()
           
 
Method Summary
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 java.sql.SQLException generateCsSQLException(StandardException se)
           
static java.sql.SQLException generateCsSQLException(java.lang.String error)
           
static java.sql.SQLException generateCsSQLException(java.lang.String error, java.lang.Object arg1)
           
static java.sql.SQLException generateCsSQLException(java.lang.String error, java.lang.Object arg1, java.lang.Object arg2)
           
static java.sql.SQLException generateCsSQLException(java.lang.String error, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
           
(package private) static java.sql.SQLException generateCsSQLException(java.lang.String error, java.lang.Object arg1, java.lang.Throwable t)
           
static SQLExceptionFactory getExceptionFactory()
          Get the exception factory specific to the version of JDBC which we are running.
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 logSQLException(java.sql.SQLException se)
          Log an SQLException to the error log or to the console if there is no error log available.
private static java.sql.SQLException newEmbedSQLException(java.lang.String messageId, int severity)
           
static java.sql.SQLException newEmbedSQLException(java.lang.String messageId, java.lang.Object[] args, int severity)
           
private static java.sql.SQLException newEmbedSQLException(java.lang.String messageId, java.lang.Object[] args, int severity, java.lang.Throwable t)
           
private static java.sql.SQLException newEmbedSQLException(java.lang.String messageId, java.lang.Object[] args, java.sql.SQLException next, int severity, java.lang.Throwable t)
          This looks up the message and sqlstate values and calls the SQLExceptionFactory method to generate the appropriate exception off of them.
(package private) static java.sql.SQLException newException(java.lang.String messageID, java.lang.Object a1, java.lang.Object a2, java.lang.Object a3)
           
(package private) static java.io.IOException newIOException(java.lang.Throwable cause)
          Create an IOException that wraps another Throwable.
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.lang.Object[] args, java.sql.SQLException next)
          Generate an SQLException which points to another SQLException nested within it with setNextException().
static void setExceptionFactory(SQLExceptionFactory factory)
          this method is called to replace the exception factory to be used to generate the SQLException or the subclass
(package private) static java.sql.SQLException setStreamFailure(java.io.IOException e)
           
(package private) static void THROWASSERT(EmbedConnection conn, java.lang.String msg)
          Mimic SanityManager.THROWASSERT in a JDBC-friendly way, and providing system cleanup for JDBC failures.
(package private) static java.sql.SQLException typeMisMatch(int targetSQLType)
           
static java.lang.String typeName(int jdbcType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exceptionFactory

private static SQLExceptionFactory exceptionFactory

logSeverityLevel

private static int logSeverityLevel
Constructor Detail

Util

public Util()
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

private 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

newEmbedSQLException

private static java.sql.SQLException newEmbedSQLException(java.lang.String messageId,
                                                          java.lang.Object[] args,
                                                          java.sql.SQLException next,
                                                          int severity,
                                                          java.lang.Throwable t)
This looks up the message and sqlstate values and calls the SQLExceptionFactory method to generate the appropriate exception off of them.


newEmbedSQLException

public static java.sql.SQLException newEmbedSQLException(java.lang.String messageId,
                                                         java.lang.Object[] args,
                                                         int severity)

newEmbedSQLException

private static java.sql.SQLException newEmbedSQLException(java.lang.String messageId,
                                                          java.lang.Object[] args,
                                                          int severity,
                                                          java.lang.Throwable t)

newEmbedSQLException

private static java.sql.SQLException newEmbedSQLException(java.lang.String messageId,
                                                          int severity)

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

THROWASSERT

static void THROWASSERT(EmbedConnection conn,
                        java.lang.String msg)
                 throws java.sql.SQLException
Mimic SanityManager.THROWASSERT in a JDBC-friendly way, and providing system cleanup for JDBC failures. We need the connection to do cleanup...

Throws:
java.sql.SQLException

newException

static java.sql.SQLException newException(java.lang.String messageID,
                                          java.lang.Object a1,
                                          java.lang.Object a2,
                                          java.lang.Object a3)

generateCsSQLException

public static java.sql.SQLException generateCsSQLException(java.lang.String error)

generateCsSQLException

public static java.sql.SQLException generateCsSQLException(java.lang.String error,
                                                           java.lang.Object arg1)

generateCsSQLException

public static java.sql.SQLException generateCsSQLException(java.lang.String error,
                                                           java.lang.Object arg1,
                                                           java.lang.Object arg2)

generateCsSQLException

public static java.sql.SQLException generateCsSQLException(java.lang.String error,
                                                           java.lang.Object arg1,
                                                           java.lang.Object arg2,
                                                           java.lang.Object arg3)

generateCsSQLException

static java.sql.SQLException generateCsSQLException(java.lang.String error,
                                                    java.lang.Object arg1,
                                                    java.lang.Throwable t)

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.lang.Object[] args,
                                              java.sql.SQLException next)
Generate an SQLException which points to another SQLException nested within it with setNextException().

Parameters:
messageId - message id
args - the arguments to the message creation
next - the next SQLException
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)

newIOException

static java.io.IOException newIOException(java.lang.Throwable cause)
Create an IOException that wraps another Throwable.

Parameters:
cause - the underlying cause of the error
Returns:
an IOException linked to cause

setExceptionFactory

public static void setExceptionFactory(SQLExceptionFactory factory)
this method is called to replace the exception factory to be used to generate the SQLException or the subclass


getExceptionFactory

public static SQLExceptionFactory getExceptionFactory()
Get the exception factory specific to the version of JDBC which we are running.


typeName

public static java.lang.String typeName(int jdbcType)

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.