本文整理汇总了Java中java.sql.Types.TIMESTAMP属性的典型用法代码示例。如果您正苦于以下问题:Java Types.TIMESTAMP属性的具体用法?Java Types.TIMESTAMP怎么用?Java Types.TIMESTAMP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.TIMESTAMP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectClauseNullString
public String getSelectClauseNullString(int sqlType) {
String literal;
switch ( sqlType ) {
case Types.VARCHAR:
case Types.CHAR:
literal = "cast(null as varchar(100))";
break;
case Types.DATE:
literal = "cast(null as date)";
break;
case Types.TIMESTAMP:
literal = "cast(null as timestamp)";
break;
case Types.TIME:
literal = "cast(null as time)";
break;
default:
literal = "cast(null as int)";
}
return literal;
}
示例2: appendEmptyRow
protected void appendEmptyRow() {
Object[] row = new Object[getModel().getColumnCount()];
for (int i = 0, I = getModel().getColumnCount(); i < I; i++) {
DBColumn col = getModel().getColumn(i);
if (col.isGenerated()) {
row[i] = SQLConstant.GENERATED;
} else if (col.hasDefault()) {
row[i] = SQLConstant.DEFAULT;
} else if (col.getJdbcType() == Types.TIMESTAMP) {
row[i] = SQLConstant.CURRENT_TIMESTAMP;
} else if (col.getJdbcType() == Types.DATE) {
row[i] = SQLConstant.CURRENT_DATE;
} else if (col.getJdbcType() == Types.TIME) {
row[i] = SQLConstant.CURRENT_TIME;
}
}
getModel().addRow(row);
}
示例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: 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);
}
}
}
示例5: setObject
@Override
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
{
checkParameterBounds(parameterIndex);
switch(targetSqlType)
{
case Types.TINYINT:
setByte(parameterIndex, ((Byte)x).byteValue());
break;
case Types.SMALLINT:
setShort(parameterIndex, ((Short)x).shortValue());
break;
case Types.INTEGER:
setInt(parameterIndex, ((Integer)x).intValue());
break;
case Types.BIGINT:
setLong(parameterIndex, ((Long)x).longValue());
break;
case Types.DOUBLE:
setDouble(parameterIndex, ((Double)x).doubleValue());
break;
case Types.DECIMAL:
setBigDecimal(parameterIndex, (BigDecimal)x);
break;
case Types.TIMESTAMP:
setTimestamp(parameterIndex, (Timestamp)x);
break;
case Types.VARBINARY:
case Types.VARCHAR:
case Types.NVARCHAR:
setString(parameterIndex, (String)x);
break;
default:
throw SQLError.get(SQLError.ILLEGAL_ARGUMENT);
}
}
示例6: 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;
}
}
示例7: getObjectToType
public static int getObjectToType(Object ob){
if (ob instanceof Integer) {
return Types.INTEGER;
}
else if (ob instanceof Boolean) {
return Types.BOOLEAN;
}
else if (ob instanceof Byte) {
return Types.BIT;
}
else if (ob instanceof Short) {
return Types.INTEGER;
}
else if (ob instanceof Float) {
return Types.FLOAT;
}
else if (ob instanceof Long) {
return Types.BIGINT;
}
else if (ob instanceof Double) {
return Types.DOUBLE;
}
else if (ob instanceof Date) {
return Types.DATE;
}
else if (ob instanceof Time) {
return Types.TIME;
}
else if (ob instanceof Timestamp) {
return Types.TIMESTAMP;
}
else if (ob instanceof String) {
return Types.VARCHAR;
}
else {
return Types.VARCHAR;
}
}
示例8: getSplitter
/**
* @return the DBSplitter implementation to use to divide the table/query into InputSplits.
*/
@Override
protected DBSplitter getSplitter(int sqlDataType) {
switch (sqlDataType) {
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
return new OracleDateSplitter();
default:
return super.getSplitter(sqlDataType);
}
}
示例9: toJavaType
/**
* Resolve a database-specific type to the Java type that should contain it.
* @param sqlType sql type
* @return the name of a Java type to hold the sql datatype, or null if none.
*/
public String toJavaType(int sqlType) {
// Mappings taken from:
// http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html
if (sqlType == Types.INTEGER) {
return "Integer";
} else if (sqlType == Types.VARCHAR) {
return "String";
} else if (sqlType == Types.CHAR) {
return "String";
} else if (sqlType == Types.LONGVARCHAR) {
return "String";
} else if (sqlType == Types.NVARCHAR) {
return "String";
} else if (sqlType == Types.NCHAR) {
return "String";
} else if (sqlType == Types.LONGNVARCHAR) {
return "String";
} else if (sqlType == Types.NUMERIC) {
return "java.math.BigDecimal";
} else if (sqlType == Types.DECIMAL) {
return "java.math.BigDecimal";
} else if (sqlType == Types.BIT) {
return "Boolean";
} else if (sqlType == Types.BOOLEAN) {
return "Boolean";
} else if (sqlType == Types.TINYINT) {
return "Integer";
} else if (sqlType == Types.SMALLINT) {
return "Integer";
} else if (sqlType == Types.BIGINT) {
return "Long";
} else if (sqlType == Types.REAL) {
return "Float";
} else if (sqlType == Types.FLOAT) {
return "Double";
} else if (sqlType == Types.DOUBLE) {
return "Double";
} else if (sqlType == Types.DATE) {
return "java.sql.Date";
} else if (sqlType == Types.TIME) {
return "java.sql.Time";
} else if (sqlType == Types.TIMESTAMP) {
return "java.sql.Timestamp";
} else if (sqlType == Types.BINARY
|| sqlType == Types.VARBINARY) {
return BytesWritable.class.getName();
} else if (sqlType == Types.CLOB) {
return ClobRef.class.getName();
} else if (sqlType == Types.BLOB
|| sqlType == Types.LONGVARBINARY) {
return BlobRef.class.getName();
} else {
// TODO(aaron): Support DISTINCT, ARRAY, STRUCT, REF, JAVA_OBJECT.
// Return null indicating database-specific manager should return a
// java data type if it can find one for any nonstandard type.
return null;
}
}
示例10: getEstimatedRowSizeInCloudSpanner
/**
* @param connection
* The connection to use to estimate the row size
* @param catalog
* The catalog of the table
* @param schemaPattern
* The schema of the table
* @param tableNamePattern
* The name of the table
* @param columnNamePattern
* The name of the column(s) to check
* @return The estimated size in bytes of one row of the specified columns
* of the specified table
* @throws SQLException
* If a database error occurs while getting the table meta data
*/
public static int getEstimatedRowSizeInCloudSpanner(Connection connection, String catalog, String schemaPattern,
String tableNamePattern, String columnNamePattern) throws SQLException
{
// There's an 8 bytes storage overhead for each column
int totalSize = 8;
try (ResultSet rs = connection.getMetaData().getColumns(catalog, schemaPattern, tableNamePattern,
columnNamePattern))
{
while (rs.next())
{
long colLength = rs.getLong("COLUMN_SIZE");
int colType = rs.getInt("DATA_TYPE");
switch (colType)
{
case Types.ARRAY:
break;
case Types.BOOLEAN:
totalSize += 1;
break;
case Types.BINARY:
totalSize += colLength;
break;
case Types.DATE:
totalSize += 4;
break;
case Types.DOUBLE:
totalSize += 8;
break;
case Types.BIGINT:
totalSize += 8;
break;
case Types.NVARCHAR:
totalSize += colLength * 2;
break;
case Types.TIMESTAMP:
totalSize += 12;
break;
}
}
}
return totalSize;
}
示例11: 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;
}
}
示例12: getSQLType
/**
* Get the SQLType for the given java.sql.Type type.
*
* @param type the java.sql.Type type specifier
* @return SQLType.the SQLType for this java.sql.Type, or null if it's not recognized
*/
public static SQLType getSQLType(int type) {
switch (type) {
case Types.BIT: return SQLType.BIT;
case Types.TINYINT: return SQLType.TINYINT;
case Types.SMALLINT: return SQLType.SMALLINT;
case Types.INTEGER: return SQLType.INTEGER;
case Types.BIGINT: return SQLType.BIGINT;
case Types.FLOAT: return SQLType.FLOAT;
case Types.REAL: return SQLType.REAL;
case Types.DOUBLE: return SQLType.DOUBLE;
case Types.NUMERIC: return SQLType.NUMERIC;
case Types.DECIMAL: return SQLType.DECIMAL;
case Types.CHAR: return SQLType.CHAR;
case Types.VARCHAR: return SQLType.VARCHAR;
case Types.LONGVARCHAR: return SQLType.LONGVARCHAR;
case Types.DATE: return SQLType.DATE;
case Types.TIME: return SQLType.TIME;
case Types.TIMESTAMP: return SQLType.TIMESTAMP;
case Types.BINARY: return SQLType.BINARY;
case Types.VARBINARY: return SQLType.VARBINARY;
case Types.LONGVARBINARY: return SQLType.LONGVARBINARY;
case Types.NULL: return SQLType.NULL;
case Types.OTHER: return SQLType.OTHER;
case Types.JAVA_OBJECT: return SQLType.JAVA_OBJECT;
case Types.DISTINCT: return SQLType.DISTINCT;
case Types.STRUCT: return SQLType.STRUCT;
case Types.ARRAY: return SQLType.ARRAY;
case Types.BLOB: return SQLType.BLOB;
case Types.CLOB: return SQLType.CLOB;
case Types.REF: return SQLType.REF;
case Types.DATALINK: return SQLType.DATALINK;
case Types.BOOLEAN: return SQLType.BOOLEAN;
case Types.LONGNVARCHAR: return SQLType.LONGVARCHAR;
case Types.NCHAR: return SQLType.CHAR;
case Types.NCLOB: return SQLType.CLOB;
case Types.NVARCHAR: return SQLType.VARCHAR;
case Types.SQLXML: return SQLType.SQLXML;
case Types.ROWID: return SQLType.ROWID;
default:
Logger.getLogger(JDBCUtils.class.getName()).log(Level.WARNING, "Unknown JDBC column type: " + type + ". Returns null.");
return null;
}
}
示例13: getEstimatedRowSizeInCloudSpanner
/**
* @param connection
* The connection to use to estimate the row size
* @param catalog
* The catalog of the table
* @param schemaPattern
* The schema of the table
* @param tableNamePattern
* The name of the table
* @param columnNamePattern
* The name of the column(s) to check
* @return The estimated size in bytes of one row of the specified columns
* of the specified table
*/
public int getEstimatedRowSizeInCloudSpanner(Connection connection, String catalog, String schemaPattern,
String tableNamePattern, String columnNamePattern) throws SQLException
{
// There's an 8 bytes storage overhead for each column
int totalSize = 8;
try (ResultSet rs = connection.getMetaData().getColumns(catalog, schemaPattern, tableNamePattern,
columnNamePattern))
{
while (rs.next())
{
long colLength = rs.getLong("COLUMN_SIZE");
int colType = rs.getInt("DATA_TYPE");
switch (colType)
{
case Types.ARRAY:
break;
case Types.BOOLEAN:
totalSize += 1;
break;
case Types.BINARY:
totalSize += colLength;
break;
case Types.DATE:
totalSize += 4;
break;
case Types.DOUBLE:
totalSize += 8;
break;
case Types.BIGINT:
totalSize += 8;
break;
case Types.NVARCHAR:
totalSize += colLength * 2;
break;
case Types.TIMESTAMP:
totalSize += 12;
break;
}
}
}
return totalSize;
}
示例14: toJavaType
/**
* Resolve a database-specific type to the Java type that should contain it.
* @param sqlType sql type
* @return the name of a Java type to hold the sql datatype, or null if none.
*/
public String toJavaType(int sqlType) {
// Mappings taken from:
// http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html
if (sqlType == Types.INTEGER) {
return "Integer";
} else if (sqlType == Types.VARCHAR) {
return "String";
} else if (sqlType == Types.CHAR) {
return "String";
} else if (sqlType == Types.LONGVARCHAR) {
return "String";
} else if (sqlType == Types.NVARCHAR) {
return "String";
} else if (sqlType == Types.NCHAR) {
return "String";
} else if (sqlType == Types.LONGNVARCHAR) {
return "String";
} else if (sqlType == Types.NUMERIC) {
return "java.math.BigDecimal";
} else if (sqlType == Types.DECIMAL) {
return "java.math.BigDecimal";
} else if (sqlType == Types.BIT) {
return "Boolean";
} else if (sqlType == Types.BOOLEAN) {
return "Boolean";
} else if (sqlType == Types.TINYINT) {
return "Integer";
} else if (sqlType == Types.SMALLINT) {
return "Integer";
} else if (sqlType == Types.BIGINT) {
return "Long";
} else if (sqlType == Types.REAL) {
return "Float";
} else if (sqlType == Types.FLOAT) {
return "Double";
} else if (sqlType == Types.DOUBLE) {
return "Double";
} else if (sqlType == Types.DATE) {
return "java.sql.Date";
} else if (sqlType == Types.TIME) {
return "java.sql.Time";
} else if (sqlType == Types.TIMESTAMP) {
return "java.sql.Timestamp";
// } else if (sqlType == Types.BINARY
// || sqlType == Types.VARBINARY) {
// return BytesWritable.class.getName();
// } else if (sqlType == Types.CLOB) {
// return ClobRef.class.getName();
// } else if (sqlType == Types.BLOB
// || sqlType == Types.LONGVARBINARY) {
// return BlobRef.class.getName();
} else {
// TODO(aaron): Support DISTINCT, ARRAY, STRUCT, REF, JAVA_OBJECT.
// Return null indicating database-specific manager should return a
// java data type if it can find one for any nonstandard type.
return null;
}
}
示例15: sqlTypeToGraphQLTypeString
protected static String sqlTypeToGraphQLTypeString(int dataType) {
String typeString;
switch (dataType) {
case Types.TINYINT:
case Types.BIGINT:
case Types.INTEGER:
case Types.SMALLINT:
typeString = "Int";
break;
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
typeString = "String";
break;
case Types.DOUBLE:
case Types.FLOAT:
case Types.REAL:
case Types.NUMERIC:
case Types.DECIMAL:
typeString = "Float";
break;
case Types.DATE:
case Types.TIMESTAMP:
case Types.TIME:
typeString = "Date";
break;
case Types.BIT:
typeString = "Boolean";
break;
case Types.OTHER:
typeString = "Object";
break;
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
typeString = "Object";
break;
default:
typeString = "Object";
break;
}
return typeString;
}