Example #1
0
  /**
   * On input from the DB, read the data from the ResultSet into the appropriate type of object to
   * be stored in the table cell.
   */
  public Object readResultSet(ResultSet rs, int index, boolean limitDataRead)
      throws java.sql.SQLException {

    byte data = rs.getByte(index);
    if (rs.wasNull()) {
      return null;
    } else {
      return Byte.valueOf(data);
    }
  }
Example #2
0
  /**
   * Get a default value for the table used to input data for a new row to be inserted into the DB.
   */
  public Object getDefaultValue(String dbDefaultValue) {
    if (dbDefaultValue != null) {
      // try to use the DB default value
      StringBuffer mbuf = new StringBuffer();
      Object newObject = validateAndConvert(dbDefaultValue, null, mbuf);

      // if there was a problem with converting, then just fall through
      // and continue as if there was no default given in the DB.
      // Otherwise, use the converted object
      if (mbuf.length() == 0) return newObject;
    }

    // no default in DB.  If nullable, use null.
    if (_isNullable) return null;

    // field is not nullable, so create a reasonable default value
    return Byte.valueOf((byte) 0);
  }