本文整理汇总了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);
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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)";
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
}