Package nz.co.transparent.client.db

Examples of nz.co.transparent.client.db.ControllerException


          columnMap.get(primaryKeyName),
          rsh);

      if (columnMapTemp == null) {
        conn.rollback();
        throw new ControllerException("GenericController: Cannot find record.");
      }

      Date oldDate = (java.util.Date) columnMap.get("date_updated");
      Date newDate = (java.util.Date) columnMapTemp.get("date_updated");
      if (!oldDate.equals(newDate)) {
        conn.rollback();
        throw new UpdaterException();
        // Signal that record has already been changed
      }

      sql = "update " + tableName;
      String parameter = null;
      String columnName = null;
      List columnNameList = null;
      List paramList = new ArrayList();
      // Iterate over columns
      Set columnSet = columnMapTemp.keySet();
      Iterator iterator = columnSet.iterator();
      int i = 0;
      while (iterator.hasNext()) {
        columnName = (String) iterator.next();

        if (columnName.equals("date_updated")) {
          parameter = "CURRENT_TIMESTAMP";
        } else {
          parameter = "?";
          paramList.add(columnMap.get(columnName));
        }

        if (i++ == 0) {
          sql += " set " + columnName + " = " + parameter;
        } else {
          sql += " ," + columnName + " = " + parameter;
        }
      }

      sql += " where (" + primaryKeyName + "=?)";
      paramList.add(columnMap.get(primaryKeyName));
      // Add primaryKey value to paramList
      int result = queryRunner.update(sql, paramList.toArray());

      if (result == 0) {
        conn.rollback();
      } else {
        conn.commit();
      }

      return result;
    } catch (SQLException se) {
      log.warning("SQL Exception: " + se.getMessage());
      try {
        conn.rollback();
      } catch (SQLException se2) {
        log.warning("SQL Exception: " + se2.getMessage());
        throw new ControllerException(se2);
      }
      throw new ControllerException(se);
    } finally {
      try {
        DbUtils.close(conn);
      } catch (SQLException se3) {
        log.warning("SQL Exception: " + se3.getMessage());
        throw new ControllerException(se3);
      }
    }
  }
View Full Code Here


      recordMap.put("is_default", Boolean.FALSE);
      updateRecord(tableName, primaryKeyName, recordMap);
    } catch (SQLException se) {
      log.warning("GenericController: " + se.getMessage());
      throw new ControllerException(se);
    } catch (UpdaterException ue) {
      throw new ControllerException(ue);
    }
  }
View Full Code Here

    try {
      queryRunner.update(sql);
    } catch (SQLException se) {
      log.warning("GenericController: " + se.getMessage());
      throw new ControllerException(se);
    }
  }
View Full Code Here

    try {
      queryRunner.update(sql);
    } catch (SQLException se) {
      log.warning("GenericController: " + se.getMessage());
      throw new ControllerException(se);
    }
  }
View Full Code Here

    try {
      queryRunner.update(sql);
    } catch (SQLException se) {
      log.warning("GenericController: " + se.getMessage());
      throw new ControllerException(se);
    }
  }
View Full Code Here

    try {
      queryRunner.update(sql);
    } catch (SQLException se) {
      log.warning("GenericController: " + se.getMessage());
      throw new ControllerException(se);
    }
  }
View Full Code Here

      log.warning("SQL Exception: " + se.getMessage());
      try {
        conn.rollback();
      } catch (SQLException se2) {
        log.warning("SQL Exception: " + se2.getMessage());
        throw new ControllerException(se2);
      }
    } finally {
      try {
        DbUtils.close(conn);
      } catch (SQLException se3) {
        log.warning("SQL Exception: " + se3.getMessage());
        throw new ControllerException(se3);
      }
    }
  }
View Full Code Here

    try {
     
      queryRunner.update(sql);
    } catch (SQLException se) {
      log.warning("SystemDBController: " + se.getMessage());
      throw new ControllerException(se);
    }
  }     
View Full Code Here

    ResultSetHandler rsh = new MapHandler();
    try {
      queryRunner.update(sql);
    } catch (SQLException se) {
      log.warning("SystemDBController: " + se.getMessage());
      throw new ControllerException(se);
    }
  }     
View Full Code Here

    ResultSetHandler rsh = new MapHandler();
    try {
      queryRunner.update(sql);
    } catch (SQLException se) {
      log.warning("SystemDBController: " + se.getMessage());
      throw new ControllerException(se);
    }
  }     
View Full Code Here

TOP

Related Classes of nz.co.transparent.client.db.ControllerException

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.