/** * Return true if the given exception occurred as a result of a lock * time out exception (WAIT clause). */ @Override public boolean isLockTimeoutException(DatabaseException e) { return (e.getInternalException() instanceof java.sql.SQLException && ((java.sql.SQLException) e.getInternalException()).getErrorCode() == 30006); }
public static DatabaseException sqlException(SQLException exception) { return sqlException(exception, false); }
public static DatabaseException sqlException(SQLException exception, Accessor accessor, AbstractSession session, boolean isCommunicationFailure) { DatabaseException databaseException = new DatabaseException(exception); databaseException.setErrorCode(SQL_EXCEPTION); databaseException.setAccessor(accessor); databaseException.setSession(session); databaseException.setCommunicationFailure(isCommunicationFailure); return databaseException; }
public static DatabaseException sqlException(SQLException exception, Call call, Accessor accessor, AbstractSession session, boolean isCommunicationFailure) { DatabaseException databaseException = new DatabaseException(exception); databaseException.setErrorCode(SQL_EXCEPTION); databaseException.setAccessor(accessor); databaseException.setCall(call); databaseException.setCommunicationFailure(isCommunicationFailure); return databaseException; }
public static DatabaseException sqlException(SQLException exception, boolean commError) { DatabaseException databaseException = new DatabaseException(exception); databaseException.setErrorCode(SQL_EXCEPTION); databaseException.setCommunicationFailure(commError); return databaseException; }
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) {
throw DatabaseException.databaseAccessorNotConnected(); throw DatabaseException.sqlException(exception, dbCall, this, session, false); ((DatabaseException)exception).setCall(dbCall); if(((DatabaseException)exception).getAccessor() == null) { ((DatabaseException)exception).setAccessor(this); throw commException; throw DatabaseException.sqlException(exception, this, session, false);
public static DatabaseException configurationErrorClassNotFound(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 DatabaseException configurationErrorNewInstanceInstantiationException(InstantiationException exception, 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; }
/** * Return true if some external transaction service is controlling transactions. */ public boolean usesExternalTransactionController() { if (this.login == null) { throw DatabaseException.databaseAccessorNotConnected(); } return this.login.shouldUseExternalTransactionController(); }
public static DatabaseException databaseAccessorNotConnected(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; }
/** * INTERNAL: * Instantiate the Driver. */ protected void instantiateDriver() throws DatabaseException { try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try{ this.driver = (Driver)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(this.driverClass)); }catch (PrivilegedActionException ex){ if (ex.getCause() instanceof IllegalAccessException){ throw (IllegalAccessException)ex.getCause(); }else if (ex.getCause() instanceof InstantiationException){ throw (InstantiationException)ex.getCause(); } throw (RuntimeException)ex.getCause(); } }else{ this.driver = (Driver)PrivilegedAccessHelper.newInstanceFromClass(this.driverClass); } } catch (InstantiationException ie) { this.clearDriverClassAndDriver(); throw DatabaseException.configurationErrorNewInstanceInstantiationException(ie, driverClass); } catch (IllegalAccessException iae) { this.clearDriverClassAndDriver(); throw DatabaseException.configurationErrorNewInstanceIllegalAccessException(iae, driverClass); } }
public Object getGeneratedValue(Accessor accessor, AbstractSession writeSession, String seqName) { if (shouldUsePreallocation()) { return null; } else { Number value = updateAndSelectSequence(accessor, writeSession, seqName, 1); if (value == null) { throw DatabaseException.errorPreallocatingSequenceNumbers(); } return value; } }
Connection nativeConnection = getConnection(); if (nativeConnection == null ) { throw DatabaseException.databaseAccessorConnectionIsNull(this, session);
int sqlErrorCode = cve.getErrorCode(); switch (sqlErrorCode) { String message = cve.getInternalException().getMessage(); String[] parts = message.split("'"); String constraintName = parts[parts.length - 1]; String message = cve.getInternalException().getMessage(); String[] parts = message.split("'"); String columnName = null;
driverClass = AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); driverClass = AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, ConversionManager.getDefaultManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); } } else { driverClass = PrivilegedAccessHelper.getClassForName(this.getDriverClassName(), true, ConversionManager.getDefaultManager().getLoader()); throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName());
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) {
throw DatabaseException.databaseAccessorNotConnected(); throw DatabaseException.sqlException(exception, dbCall, this, session, false); ((DatabaseException)exception).setCall(dbCall); if(((DatabaseException)exception).getAccessor() == null) { ((DatabaseException)exception).setAccessor(this); throw DatabaseException.sqlException(exception, this, session, false);
public static DatabaseException errorPreallocatingSequenceNumbers() { 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 DatabaseException configurationErrorNewInstanceInstantiationException(InstantiationException exception, 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; }