Package com.webobjects.jdbcadaptor

Examples of com.webobjects.jdbcadaptor.JDBCAdaptorException


      }
      if (t instanceof NSForwardException) {
        return originalThrowable(((NSForwardException)t).originalException());
      }
         if (t instanceof JDBCAdaptorException) {
           JDBCAdaptorException ex = (JDBCAdaptorException)t;
        if(ex.sqlException() != null) {
          return originalThrowable(ex.sqlException());
        }
      }
         if (t instanceof SQLException) {
        SQLException ex = (SQLException)t;
        if(ex.getNextException() != null) {
          return originalThrowable(ex.getNextException());
        }
      }
      if (t instanceof Exception) {
        Exception ex = (Exception)t;
        if(ex.getCause() != null) {
          return originalThrowable(ex.getCause());
        }
      }
      return t;
    }
View Full Code Here


  }
 
  public Object newValueForDate(Object value) {
    if(valueFactoryMethod() != null) {
      if(!(value instanceof Date)) {
        throw new JDBCAdaptorException(new StringBuilder().append(value).append(" of type ").append(value.getClass().getName()).append(" is not a valid Date type.  You must use java.sql.Timestamp, java.sql.Date, or java.sql.Time").toString(), null);
      }
      Date date = (Date)value;
      //Call the custom factory method
      try {
        if(valueFactoryClass() != null) {
          Class<?> factoryClass = valueFactoryClass();
          return valueFactoryMethod().invoke(factoryClass, date);
        }
        Class<?> c = _NSUtilities.classWithName(className());
        return valueFactoryMethod().invoke(c, date);
      } catch(IllegalAccessException e) {
        throw NSForwardException._runtimeExceptionForThrowable(e);
      } catch(IllegalArgumentException e) {
        throw NSForwardException._runtimeExceptionForThrowable(e);
      } catch(NoSuchMethodException e) {
        throw NSForwardException._runtimeExceptionForThrowable(e);
      } catch(InvocationTargetException e) {
        throw NSForwardException._runtimeExceptionForThrowable(e);
      }
    } else {
      if(value instanceof Timestamp) {
        return new NSTimestamp((Timestamp)value);
      }
      if(value instanceof Date) {
        Date temp = (Date)value;
        return new NSTimestamp(temp.getTime());
      } else {
        throw new JDBCAdaptorException(new StringBuilder().append(value).append(" of type ").append(value.getClass().getName()).append(" is not a valid Date type.  You must use java.sql.Timestamp, java.sql.Date, or java.sql.Time").toString(), null);
      }
    }
  }
View Full Code Here

        if (gae.userInfo() != null) {
          EOAdaptorOperation failedOperation = (EOAdaptorOperation) gae.userInfo().objectForKey(EOAdaptorChannel.FailedAdaptorOperationKey);
          if (failedOperation != null) {
            Throwable t = failedOperation.exception();
            if (t instanceof JDBCAdaptorException) {
              JDBCAdaptorException jdbcEx = (JDBCAdaptorException) t;
              SQLException sqlEx = jdbcEx.sqlException();
              if (sqlEx != null && UNIQUE_CONSTRAINT_EXCEPTION_STATE.equals(sqlEx.getSQLState())) {
                String message = sqlEx.getMessage();
                MessageFormat format = new MessageFormat(UNIQUE_CONSTRAINT_MESSAGE_FORMAT);
                try {
                  Object[] objs = format.parse(message);
View Full Code Here

    public void rollbackTransaction() {
      if (!hasOpenTransaction()) {
        return;
      }
      if (((Number)ERXKeyValueCodingUtilities.privateValueForKey(this, "_fetchesInProgress")).intValue() > 0) {
        throw new JDBCAdaptorException("Cannot rollbackTransaction() while a fetch is in progress", null);
      }
      if (_delegateRespondsTo_shouldRollback && !_delegate.booleanPerform("adaptorContextShouldRollback", this))
        return;
      try {
        if (_connectionSupportTransaction) {
          // AK: only roll back if the connection isn't closed.
          if(!_jdbcConnection.isClosed()) {
            _jdbcConnection.rollback();
          }
        }
      }
      catch (SQLException sqlexception) {
        throw new JDBCAdaptorException(sqlexception);
      }
      transactionDidRollback();
      if (_delegateRespondsTo_didRollback) {
        _delegate.perform("adaptorContextDidRollback", this);
      }
View Full Code Here

TOP

Related Classes of com.webobjects.jdbcadaptor.JDBCAdaptorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.