當前位置: 首頁>>代碼示例>>Java>>正文


Java Types.TIME屬性代碼示例

本文整理匯總了Java中java.sql.Types.TIME屬性的典型用法代碼示例。如果您正苦於以下問題:Java Types.TIME屬性的具體用法?Java Types.TIME怎麽用?Java Types.TIME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.sql.Types的用法示例。


在下文中一共展示了Types.TIME屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertFromType

int convertFromType(int type) {

        //Correct a bug in Informix JDBC driver that maps:
        // DATETIME YEAR TO FRACTION to TIME and
        // DATETIME HOUR TO SECOND to TIMESTAMP
        if (type == Types.TIMESTAMP) {
            type = Types.TIME;

            tracer.trace("Converted INFORMIX TIMESTAMP to TIME");
        } else if (type == Types.TIME) {
            type = Types.TIMESTAMP;

            tracer.trace("Converted INFORMIX TIME to TIMESTAMP");
        }

        return (type);
    }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:17,代碼來源:InformixTransferHelper.java

示例2: resultSetColToLong

/** Retrieve the value from the column in a type-appropriate manner and return
    its timestamp since the epoch. If the column is null, then return Long.MIN_VALUE.
    This will cause a special split to be generated for the NULL case, but may also
    cause poorly-balanced splits if most of the actual dates are positive time
    since the epoch, etc.
  */
private long resultSetColToLong(ResultSet rs, int colNum, int sqlDataType) throws SQLException {
  try {
    switch (sqlDataType) {
    case Types.DATE:
      return rs.getDate(colNum).getTime();
    case Types.TIME:
      return rs.getTime(colNum).getTime();
    case Types.TIMESTAMP:
      return rs.getTimestamp(colNum).getTime();
    default:
      throw new SQLException("Not a date-type field");
    }
  } catch (NullPointerException npe) {
    // null column. return minimum long value.
    LOG.warn("Encountered a NULL date in the split column. Splits may be poorly balanced.");
    return Long.MIN_VALUE;
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:24,代碼來源:DateSplitter.java

示例3: convertToType

int convertToType(int type) {

        //Correct a bug in Informix JDBC driver that maps:
        // DATETIME YEAR TO FRACTION to TIME and
        // DATETIME HOUR TO SECOND to TIMESTAMP
        if (type == Types.TIMESTAMP) {
            type = Types.TIME;

            tracer.trace("Converted TIMESTAMP to INFORMIX TIME");
        } else if (type == Types.TIME) {
            type = Types.TIMESTAMP;

            tracer.trace("Converted TIME to INFORMIX TIMESTAMP");
        }

        return (type);
    }
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:17,代碼來源:InformixTransferHelper.java

示例4: areSqlTypesCompatible

private boolean areSqlTypesCompatible(int target, int source) {
	switch ( target ) {
		case Types.TIMESTAMP:
			return source == Types.DATE || source == Types.TIME || source == Types.TIMESTAMP;
		case Types.DATE:
			return source == Types.DATE || source == Types.TIMESTAMP;
		case Types.TIME:
			return source == Types.TIME || source == Types.TIMESTAMP;
		default:
			return target == source;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:IntoClause.java

示例5: isCaseSensitive

/**
 * Does a column's case matter?
 * 
 * @param column
 *            the first column is 1, the second is 2...
 * 
 * @return true if so
 * 
 * @throws java.sql.SQLException
 *             if a database access error occurs
 */
public boolean isCaseSensitive(int column) throws java.sql.SQLException {
    Field field = getField(column);

    int sqlType = field.getSQLType();

    switch (sqlType) {
        case Types.BIT:
        case Types.TINYINT:
        case Types.SMALLINT:
        case Types.INTEGER:
        case Types.BIGINT:
        case Types.FLOAT:
        case Types.REAL:
        case Types.DOUBLE:
        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            return false;

        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:

            if (field.isBinary()) {
                return true;
            }

            String collationName = field.getCollation();

            return ((collationName != null) && !collationName.endsWith("_ci"));

        default:
            return true;
    }
}
 
開發者ID:Jugendhackt,項目名稱:OpenVertretung,代碼行數:46,代碼來源:ResultSetMetaData.java

示例6: getSQLValue

public String getSQLValue(Table table, Row row, int index) {
	Column column = table.getColumns().get(index);
	int type = column.getDataType();
	if (row.get(index) == null) {
		return "null";
	} else {
		switch (type) {
		case Types.CHAR:
		case Types.VARCHAR:
		case Types.LONGNVARCHAR:
		case Types.NCHAR:
		case Types.NVARCHAR:
		case Types.LONGVARCHAR:
			return "\"" + row.getString(index) + "\"";

		case Types.DATE:
			return "\"" + DATE_FORMAT_THREAD_LOCAL.get().format(row.getDate(index)) + "\"";

		case Types.TIME:
			return "\"" + TIME_FORMAT_THREAD_LOCAL.get().format(row.getDate(index)) + "\"";

		case Types.TIMESTAMP:
			return "\"" + DATE_TIME_FORMAT_THREAD_LOCAL.get().format(row.getDate(index)) + "\"";

		default:
			return row.getString(index);
		}

	}
}
 
開發者ID:ZHENFENG13,項目名稱:My-Blog,代碼行數:30,代碼來源:Backup.java

示例7: getSelectClauseNullString

@Override
public String getSelectClauseNullString(int sqlType) {
	switch(sqlType) {
		case Types.VARCHAR:
		case Types.CHAR:
			return "to_char(null)";
		case Types.DATE:
		case Types.TIMESTAMP:
		case Types.TIME:
			return "to_date(null)";
		default:
			return "to_number(null)";
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:OracleDialect.java

示例8: longToDate

/**  Parse the long-valued timestamp into the appropriate SQL date type. */
public static Date longToDate(long val, int sqlDataType) {
  switch (sqlDataType) {
  case Types.DATE:
    return new java.sql.Date(val);
  case Types.TIME:
    return new java.sql.Time(val);
  case Types.TIMESTAMP:
    return new java.sql.Timestamp(val);
  default: // Shouldn't ever hit this case.
    return null;
  }
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:13,代碼來源:DateSplitter.java

示例9: isDateTimeColumn

/**
 * Determine if a column is date/time.
 * @return true if column type is TIMESTAMP, DATE, or TIME.
 */
private boolean isDateTimeColumn(int columnType) {
  return (columnType == Types.TIMESTAMP)
      || (columnType == Types.DATE)
      || (columnType == Types.TIME);
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:9,代碼來源:ImportTool.java

示例10: getFieldType

/**
 * 根據Types獲取字段類型
 *
 * @see Types
 * @return 對應字段的java類型
 */
public static FieldType getFieldType(Integer sqlType) {
    FieldType fieldType = sqlTypes.get("UNKNOWN");
    if (sqlType == null) {
        return fieldType;
    }

    // https://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html
    if (sqlType == Types.INTEGER) {
        fieldType = sqlTypes.get("INTEGER");
    } else if (sqlType == Types.VARCHAR) {
        fieldType = sqlTypes.get("STRING");
    } else if (sqlType == Types.CHAR) {
        fieldType = sqlTypes.get("STRING");
    } else if (sqlType == Types.LONGVARCHAR) {
        fieldType = sqlTypes.get("STRING");
    } else if (sqlType == Types.NVARCHAR) {
        fieldType = sqlTypes.get("STRING");
    } else if (sqlType == Types.NCHAR) {
        fieldType = sqlTypes.get("STRING");
    } else if (sqlType == Types.LONGNVARCHAR) {
        fieldType = sqlTypes.get("STRING");
    } else if (sqlType == Types.NUMERIC) {
        fieldType = sqlTypes.get("DECIMAL");
    } else if (sqlType == Types.DECIMAL) {
        fieldType = sqlTypes.get("DECIMAL");
    } else if (sqlType == Types.BIT) {
        fieldType = sqlTypes.get("BOOLEAN");
    } else if (sqlType == Types.BOOLEAN) {
        fieldType = sqlTypes.get("BOOLEAN");
    } else if (sqlType == Types.TINYINT) {
        fieldType = sqlTypes.get("INTEGER");
    } else if (sqlType == Types.SMALLINT) {
        fieldType = sqlTypes.get("INTEGER");
    } else if (sqlType == Types.BIGINT) {
        fieldType = sqlTypes.get("BIGINT");
    } else if (sqlType == Types.REAL) {
        fieldType = sqlTypes.get("REAL");
    } else if (sqlType == Types.FLOAT) {
        fieldType = sqlTypes.get("FLOAT");
    } else if (sqlType == Types.DOUBLE) {
        fieldType = sqlTypes.get("DOUBLE");
    } else if (sqlType == Types.DATE) {
        // java.sql.Date ?
        fieldType = sqlTypes.get("DATE");
    } else if (sqlType == Types.TIME) {
        // java.sql.Time ?
        fieldType = sqlTypes.get("TIME");
    } else if (sqlType == Types.TIMESTAMP) {
        // java.sql.Timestamp ?
        fieldType = sqlTypes.get("TIMESTAMP");
    } else if (sqlType == Types.BINARY
            || sqlType == Types.VARBINARY) {
        fieldType = sqlTypes.get("BINARY");
    } else if (sqlType == Types.CLOB) {
        fieldType = sqlTypes.get("CLOB");
    } else if (sqlType == Types.BLOB
            || sqlType == Types.LONGVARBINARY) {
        fieldType = sqlTypes.get("BLOB");
    } else {
        // DISTINCT, ARRAY, STRUCT, REF, JAVA_OBJECT.
        return fieldType;
    }
    return fieldType;
}
 
開發者ID:hykes,項目名稱:CodeGen,代碼行數:70,代碼來源:ParserUtils.java

示例11: jdbcTypeToClass

/**
 * Get the Java type which corresponds to given SQL type.
 * @param type SQL type
 * @return The Java type
 */
public static Class<?> jdbcTypeToClass(int type) {
	Class<?> result = Object.class;

	switch (type) {
	case Types.CHAR:
	case Types.VARCHAR:
	case Types.LONGVARCHAR:
		result = String.class;
		break;

	case Types.NUMERIC:
	case Types.DECIMAL:
		result = java.math.BigDecimal.class;
		break;

	case Types.BIT:
		result = Boolean.class;
		break;

	case Types.TINYINT:
		result = Byte.class;
		break;

	case Types.SMALLINT:
		result = Short.class;
		break;

	case Types.INTEGER:
		result = Integer.class;
		break;

	case Types.BIGINT:
		result = Long.class;
		break;

	case Types.REAL:
	case Types.FLOAT:
		result = Float.class;
		break;

	case Types.DOUBLE:
		result = Double.class;
		break;

	case Types.BINARY:
	case Types.VARBINARY:
	case Types.LONGVARBINARY:
		result = byte[].class;
		break;

	case Types.DATE:
		result = java.sql.Date.class;
		break;

	case Types.TIME:
		result = java.sql.Time.class;
		break;

	case Types.TIMESTAMP:
		result = java.sql.Timestamp.class;
		break;
	default:
		break;
	}

	return result;
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jdbc,代碼行數:72,代碼來源:JdbcDatastoreUtils.java

示例12: setParamValue

private void setParamValue(PreparedStatement ps, int psIdx, ResultSetRow row, int rsIdx, int sqlType) throws SQLException {
    byte[] val = row.getColumnValue(rsIdx);
    if (val == null) {
        ps.setNull(psIdx, Types.NULL);
        return;
    }
    switch (sqlType) {
        case Types.NULL:
            ps.setNull(psIdx, Types.NULL);
            break;
        case Types.TINYINT:
        case Types.SMALLINT:
        case Types.INTEGER:
            ps.setInt(psIdx, row.getInt(rsIdx));
            break;
        case Types.BIGINT:
            ps.setLong(psIdx, row.getLong(rsIdx));
            break;
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
        case Types.DECIMAL:
        case Types.NUMERIC:
            ps.setString(psIdx, row.getString(rsIdx, this.charEncoding, this.connection));
            break;
        case Types.DATE:
            ps.setDate(psIdx, row.getDateFast(rsIdx, this.connection, this, this.fastDefaultCal), this.fastDefaultCal);
            break;
        case Types.TIMESTAMP:
            ps.setTimestamp(psIdx, row.getTimestampFast(rsIdx, this.fastDefaultCal, this.connection.getDefaultTimeZone(), false, this.connection, this));
            break;
        case Types.TIME:
            ps.setTime(psIdx, row.getTimeFast(rsIdx, this.fastDefaultCal, this.connection.getDefaultTimeZone(), false, this.connection, this));
            break;
        case Types.FLOAT:
        case Types.DOUBLE:
        case Types.REAL:
        case Types.BOOLEAN:
            ps.setBytesNoEscapeNoQuotes(psIdx, val);
            break;
        /*
         * default, but also explicitly for following types:
         * case Types.BINARY:
         * case Types.BLOB:
         */
        default:
            ps.setBytes(psIdx, val);
            break;
    }

}
 
開發者ID:Jugendhackt,項目名稱:OpenVertretung,代碼行數:51,代碼來源:UpdatableResultSet.java

示例13: setParamValue

private synchronized void setParamValue(PreparedStatement ps, int psIdx, ResultSetRow row, int rsIdx, int sqlType) throws SQLException {

        byte[] val = row.getColumnValue(rsIdx);
        if (val == null) {
            ps.setNull(psIdx, Types.NULL);
            return;
        }
        switch (sqlType) {
            case Types.NULL:
                ps.setNull(psIdx, Types.NULL);
                break;
            case Types.TINYINT:
            case Types.SMALLINT:
            case Types.INTEGER:
                ps.setInt(psIdx, row.getInt(rsIdx));
                break;
            case Types.BIGINT:
                ps.setLong(psIdx, row.getLong(rsIdx));
                break;
            case Types.CHAR:
            case Types.VARCHAR:
            case Types.LONGVARCHAR:
            case Types.DECIMAL:
            case Types.NUMERIC:
                ps.setString(psIdx, row.getString(rsIdx, this.charEncoding, this.connection));
                break;
            case Types.DATE:
                ps.setDate(psIdx, row.getDateFast(rsIdx, this.connection, this, this.fastDefaultCal), this.fastDefaultCal);
                break;
            case Types.TIMESTAMP:
                ps.setTimestamp(psIdx, row.getTimestampFast(rsIdx, this.fastDefaultCal, this.connection.getDefaultTimeZone(), false, this.connection, this));
                break;
            case Types.TIME:
                ps.setTime(psIdx, row.getTimeFast(rsIdx, this.fastDefaultCal, this.connection.getDefaultTimeZone(), false, this.connection, this));
                break;
            case Types.FLOAT:
            case Types.DOUBLE:
            case Types.REAL:
            case Types.BOOLEAN:
                ps.setBytesNoEscapeNoQuotes(psIdx, val);
                break;
            /*
             * default, but also explicitly for following types:
             * case Types.BINARY:
             * case Types.BLOB:
             */
            default:
                ps.setBytes(psIdx, val);
                break;
        }

    }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:52,代碼來源:UpdatableResultSet.java

示例14: makeDbColDefinition

public BaseDbColDefinition makeDbColDefinition()
{
	BaseDbColDefinition dbColDef = null;
	if(m_nTypeId == Types.CHAR)
	{
		dbColDef = new DbColDefinitionChar(this);
	}
	else if(m_nTypeId == Types.DECIMAL)	// Unsupported type in jlib, but supported in nacaRT
	{
		dbColDef = new DbColDefinitionDecimal(this);
	}			
	else if(m_nTypeId == Types.TIME)
	{
		dbColDef = new DbColDefinitionTime(this);
	}
	else if(m_nTypeId == Types.TIMESTAMP)
	{
		dbColDef = new DbColDefinitionTimestamp(this);
	}
	else if(m_nTypeId == Types.DATE)
	{
		dbColDef = new DbColDefinitionDate(this);
	}
	else if(m_nTypeId == Types.VARCHAR)
	{
		dbColDef = new DbColDefinitionVarchar(this);
	}
	else if(m_nTypeId == Types.LONGVARCHAR)
	{
		dbColDef = new DbColDefinitionLongVarchar(this);
	}
	else if(m_nTypeId == Types.SMALLINT)
	{
		dbColDef = new DbColDefinitionSmallint(this);
	}
	else if(m_nTypeId == Types.INTEGER)
	{
		dbColDef = new DbColDefinitionInteger(this);
	}
	else if(m_nTypeId == Types.DOUBLE)
	{
		dbColDef = new DbColDefinitionDouble(this);
	}

	return dbColDef;
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:46,代碼來源:ColDescriptionInfo.java

示例15: getSplitter

/**
 * @return the DBSplitter implementation to use to divide the table/query
 * into InputSplits.
 */
public DBSplitter getSplitter(int sqlDataType, long splitLimit, String rangeStyle) {
  switch (sqlDataType) {
      case Types.NUMERIC:
      case Types.DECIMAL:
        if(splitLimit >= 0) {
          throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
        }
        return new BigDecimalSplitter();

      case Types.BIT:
      case Types.BOOLEAN:
        if(splitLimit >= 0) {
          throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
        }
      return new BooleanSplitter();

      case Types.INTEGER:
      case Types.TINYINT:
      case Types.SMALLINT:
      case Types.BIGINT:
        return new IntegerSplitter();

      case Types.REAL:
      case Types.FLOAT:
      case Types.DOUBLE:
        if(splitLimit >= 0) {
          throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
        }
        return new FloatSplitter();

      case Types.NVARCHAR:
      case Types.NCHAR:
        if(splitLimit >= 0) {
          throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
        }
        return new NTextSplitter(rangeStyle);

      case Types.CHAR:
      case Types.VARCHAR:
      case Types.LONGVARCHAR:
        if(splitLimit >= 0) {
           throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
        }
        return new TextSplitter(rangeStyle);

      case Types.DATE:
      case Types.TIME:
      case Types.TIMESTAMP:
        return new DateSplitter();

      default:
      // TODO: Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT, CLOB,
      // BLOB, ARRAY, STRUCT, REF, DATALINK, and JAVA_OBJECT.
      if(splitLimit >= 0) {
      throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
      }
      return null;
  }
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:63,代碼來源:DataDrivenDBInputFormat.java


注:本文中的java.sql.Types.TIME屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。