FileDocCategorySizeDatePackage
DatabaseException.javaAPI DocGlassfish v2 API15395Tue May 22 16:54:18 BST 2007oracle.toplink.essentials.exceptions

DatabaseException

public class DatabaseException extends TopLinkException

Purpose: Wrapper for any database exception that occurred through TopLink.

Fields Summary
protected SQLException
exception
protected transient Call
call
protected transient DatabaseQuery
query
protected transient AbstractRecord
queryArguments
protected transient Accessor
accessor
public static final int
SQL_EXCEPTION
public static final int
CONFIGURATION_ERROR_CLASS_NOT_FOUND
public static final int
DATABASE_ACCESSOR_NOT_CONNECTED
public static final int
ERROR_READING_BLOB_DATA
public static final int
COULD_NOT_CONVERT_OBJECT_TYPE
public static final int
LOGOUT_WHILE_TRANSACTION_IN_PROGRESS
public static final int
SEQUENCE_TABLE_INFORMATION_NOT_COMPLETE
public static final int
ERROR_PREALLOCATING_SEQUENCE_NUMBERS
public static final int
CANNOT_REGISTER_SYNCHRONIZATIONLISTENER_FOR_UNITOFWORK
public static final int
SYNCHRONIZED_UNITOFWORK_DOES_NOT_SUPPORT_COMMITANDRESUME
public static final int
CONFIGURATION_ERROR_NEW_INSTANCE_INSTANTIATION_EXCEPTION
public static final int
CONFIGURATION_ERROR_NEW_INSTANCE_ILLEGAL_ACCESS_EXCEPTION
public static final int
TRANSACTION_MANAGER_NOT_SET_FOR_JTS_DRIVER
public static final int
ERROR_RETRIEVE_DB_METADATA_THROUGH_JDBC_CONNECTION
Constructors Summary
protected DatabaseException(String message)
INTERNAL: TopLink exceptions should only be thrown by the TopLink code.


                    
       
        super(message);
    
protected DatabaseException(SQLException exception)
INTERNAL: TopLink exceptions should only be thrown by the TopLink code.

        super(exception.toString(), exception);
    
Methods Summary
public static oracle.toplink.essentials.exceptions.DatabaseExceptioncannotRegisterSynchronizatonListenerForUnitOfWork(java.lang.Exception e)

        Object[] args = { e };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, CANNOT_REGISTER_SYNCHRONIZATIONLISTENER_FOR_UNITOFWORK, args));
        databaseException.setErrorCode(CANNOT_REGISTER_SYNCHRONIZATIONLISTENER_FOR_UNITOFWORK);
        databaseException.setInternalException(e);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionconfigurationErrorClassNotFound(java.lang.String className)

        Object[] args = { className };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, CONFIGURATION_ERROR_CLASS_NOT_FOUND, args));
        databaseException.setErrorCode(CONFIGURATION_ERROR_CLASS_NOT_FOUND);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionconfigurationErrorNewInstanceIllegalAccessException(java.lang.IllegalAccessException exception, java.lang.Class javaClass)

        Object[] args = { javaClass };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, CONFIGURATION_ERROR_NEW_INSTANCE_ILLEGAL_ACCESS_EXCEPTION, args));
        databaseException.setErrorCode(CONFIGURATION_ERROR_NEW_INSTANCE_ILLEGAL_ACCESS_EXCEPTION);
        databaseException.setInternalException(exception);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionconfigurationErrorNewInstanceInstantiationException(java.lang.InstantiationException exception, java.lang.Class javaClass)

        Object[] args = { javaClass };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, CONFIGURATION_ERROR_NEW_INSTANCE_INSTANTIATION_EXCEPTION, args));
        databaseException.setErrorCode(CONFIGURATION_ERROR_NEW_INSTANCE_INSTANTIATION_EXCEPTION);
        databaseException.setInternalException(exception);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptioncouldNotConvertObjectType(int type)

        Object[] args = { CR, new Integer(type) };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, COULD_NOT_CONVERT_OBJECT_TYPE, args));
        databaseException.setErrorCode(COULD_NOT_CONVERT_OBJECT_TYPE);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptiondatabaseAccessorNotConnected()

        Object[] args = {  };
        String message = oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator.buildMessage(DatabaseException.class, DATABASE_ACCESSOR_NOT_CONNECTED, args);
        DatabaseException databaseException = new DatabaseException(message);
        databaseException.setErrorCode(DATABASE_ACCESSOR_NOT_CONNECTED);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptiondatabaseAccessorNotConnected(oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor databaseAccessor)

        Object[] args = {  };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, DATABASE_ACCESSOR_NOT_CONNECTED, args));
        databaseException.setErrorCode(DATABASE_ACCESSOR_NOT_CONNECTED);
        databaseException.setAccessor(databaseAccessor);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionerrorPreallocatingSequenceNumbers()

        Object[] args = {  };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, ERROR_PREALLOCATING_SEQUENCE_NUMBERS, args));
        databaseException.setErrorCode(ERROR_PREALLOCATING_SEQUENCE_NUMBERS);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionerrorReadingBlobData()

        Object[] args = {  };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, ERROR_READING_BLOB_DATA, args));
        databaseException.setErrorCode(ERROR_READING_BLOB_DATA);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionerrorRetrieveDbMetadataThroughJDBCConnection()

        Object[] args = {  };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, ERROR_RETRIEVE_DB_METADATA_THROUGH_JDBC_CONNECTION, args));
        databaseException.setErrorCode(ERROR_RETRIEVE_DB_METADATA_THROUGH_JDBC_CONNECTION);
        return databaseException;
    
public oracle.toplink.essentials.internal.databaseaccess.AccessorgetAccessor()
PUBLIC: Return the accessor.

        return accessor;
    
public oracle.toplink.essentials.queryframework.CallgetCall()
PUBLIC: Return the call that caused the exception.

        return call;
    
public intgetDatabaseErrorCode()
PUBLIC: This is the database error number. Since it is possible to have no internal exception the errorCode will be zero in this case.

        if (getInternalException() == null) {
            return super.getErrorCode();
        }
        return ((SQLException)getInternalException()).getErrorCode();
    
public java.lang.StringgetMessage()
PUBLIC: This is the database error message.

        if (getInternalException() == null) {
            return super.getMessage();
        } else {
            StringWriter writer = new StringWriter();
            writer.write(super.getMessage());
            writer.write(cr());
            writer.write(getIndentationString());
            writer.write(ExceptionMessageGenerator.getHeader("ErrorCodeHeader"));
            if (getInternalException() instanceof SQLException) {
                writer.write(Integer.toString(((SQLException)getInternalException()).getErrorCode()));
            } else {
                writer.write("000");
            }
            if (getCall() != null) {
                writer.write(cr());
                writer.write(getIndentationString());
                writer.write(ExceptionMessageGenerator.getHeader("CallHeader"));
                if (getAccessor() != null) {
                    writer.write(getCall().getLogString(getAccessor()));
                } else {
                    writer.write(getCall().toString());
                }
            }
            if (getQuery() != null) {
                writer.write(cr());
                writer.write(getIndentationString());
                writer.write(ExceptionMessageGenerator.getHeader("QueryHeader"));
                try {
                    writer.write(getQuery().toString());
                } catch (RuntimeException badTooString) {
                }
            }
            return writer.toString();
        }
    
public oracle.toplink.essentials.queryframework.DatabaseQuerygetQuery()
PUBLIC: This method returns the databaseQuery. DatabaseQuery is a visible class to the TopLink user. Users create an appropriate query by creating an instance of a concrete subclasses of DatabaseQuery.

        return query;
    
public oracle.toplink.essentials.sessions.RecordgetQueryArgumentsRecord()
PUBLIC: Return the query argements used in the original query when exception is thrown

        return queryArguments;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionlogoutWhileTransactionInProgress()

        Object[] args = {  };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, LOGOUT_WHILE_TRANSACTION_IN_PROGRESS, args));
        databaseException.setErrorCode(LOGOUT_WHILE_TRANSACTION_IN_PROGRESS);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionsequenceTableInformationNotComplete()

        Object[] args = {  };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, SEQUENCE_TABLE_INFORMATION_NOT_COMPLETE, args));
        databaseException.setErrorCode(SEQUENCE_TABLE_INFORMATION_NOT_COMPLETE);
        return databaseException;
    
public voidsetAccessor(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor)
INTERNAL: Set the Accessor.

        this.accessor = accessor;
    
public voidsetCall(oracle.toplink.essentials.queryframework.Call call)
INTERNAL: Set the call that caused the exception.

        this.call = call;
    
public voidsetQuery(oracle.toplink.essentials.queryframework.DatabaseQuery query)
PUBLIC: This method set the databaseQuery. DatabaseQuery is a visible class to the TopLink user. Users create an appropriate query by creating an instance of a concrete subclasses of DatabaseQuery.

        this.query = query;
    
public voidsetQueryArguments(oracle.toplink.essentials.internal.sessions.AbstractRecord queryArguments)
PUBLIC: Set the query argements used in the original query when exception is thrown

        this.queryArguments = queryArguments;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionsqlException(java.sql.SQLException exception)

        DatabaseException databaseException = new DatabaseException(exception);
        databaseException.setErrorCode(SQL_EXCEPTION);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionsqlException(java.sql.SQLException exception, oracle.toplink.essentials.internal.databaseaccess.Accessor accessor, oracle.toplink.essentials.internal.sessions.AbstractSession session)

        DatabaseException databaseException = new DatabaseException(exception);
        databaseException.setErrorCode(SQL_EXCEPTION);
        databaseException.setAccessor(accessor);
        databaseException.setSession(session);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionsqlException(java.sql.SQLException exception, oracle.toplink.essentials.queryframework.Call call, oracle.toplink.essentials.internal.databaseaccess.Accessor accessor, oracle.toplink.essentials.internal.sessions.AbstractSession session)

        DatabaseException databaseException = new DatabaseException(exception);
        databaseException.setErrorCode(SQL_EXCEPTION);
        databaseException.setAccessor(accessor);
        databaseException.setCall(call);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptionsynchronizedUnitOfWorkDoesNotSupportCommitAndResume()

        Object[] args = {  };

        String message = oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator.buildMessage(DatabaseException.class, SYNCHRONIZED_UNITOFWORK_DOES_NOT_SUPPORT_COMMITANDRESUME, args);
        DatabaseException databaseException = new DatabaseException(message);
        databaseException.setErrorCode(SYNCHRONIZED_UNITOFWORK_DOES_NOT_SUPPORT_COMMITANDRESUME);
        return databaseException;
    
public static oracle.toplink.essentials.exceptions.DatabaseExceptiontransactionManagerNotSetForJTSDriver()

        Object[] args = {  };

        DatabaseException databaseException = new DatabaseException(ExceptionMessageGenerator.buildMessage(DatabaseException.class, TRANSACTION_MANAGER_NOT_SET_FOR_JTS_DRIVER, args));
        databaseException.setErrorCode(TRANSACTION_MANAGER_NOT_SET_FOR_JTS_DRIVER);
        return databaseException;