List of usage examples for java.sql JDBCType TIMESTAMP
JDBCType TIMESTAMP
To view the source code for java.sql JDBCType TIMESTAMP.
Click Source Link
From source file:com.microsoft.sqlserver.testframework.sqlType.SqlDateTime2.java
public SqlDateTime2() { super("datetime2", JDBCType.TIMESTAMP, null, null); try {/*from ww w . ja va2s . com*/ minvalue = new Timestamp(dateFormat.parse((String) SqlTypeValue.DATETIME2.minValue).getTime()); maxvalue = new Timestamp(dateFormat.parse((String) SqlTypeValue.DATETIME2.maxValue).getTime()); } catch (ParseException ex) { fail(ex.getMessage()); } this.precision = 7; this.variableLengthType = VariableLengthType.Precision; generatePrecision(); formatter = new DateTimeFormatterBuilder().appendPattern(basePattern) .appendFraction(ChronoField.NANO_OF_SECOND, 0, this.precision, true).toFormatter(); }
From source file:com.microsoft.sqlserver.testframework.DBTable.java
/** * // ww w . ja v a 2s . c o m * @param colNum * @return <code>true</code> if value can be passed as String for the column */ boolean passDataAsString(int colNum) { return (JDBCType.CHAR == getColumn(colNum).getJdbctype() || JDBCType.VARCHAR == getColumn(colNum).getJdbctype() || JDBCType.NCHAR == getColumn(colNum).getJdbctype() || JDBCType.NVARCHAR == getColumn(colNum).getJdbctype() || JDBCType.TIMESTAMP == getColumn(colNum).getJdbctype() || JDBCType.DATE == getColumn(colNum).getJdbctype() || JDBCType.TIME == getColumn(colNum).getJdbctype() || JDBCType.LONGVARCHAR == getColumn(colNum).getJdbctype() || JDBCType.LONGNVARCHAR == getColumn(colNum).getJdbctype()); }
From source file:org.hswebframework.web.dao.mybatis.builder.EasyOrmSqlBuilder.java
protected RDBTableMetaData createMeta(String tableName, String resultMapId) { RDBDatabaseMetaData active = getActiveDatabase(); String cacheKey = tableName.concat("-").concat(resultMapId); Map<String, RDBTableMetaData> cache = metaCache.get(active); RDBTableMetaData cached = cache.get(cacheKey); if (cached != null) { return cached; }//from w w w . ja v a 2 s . c om RDBTableMetaData rdbTableMetaData = new RDBTableMetaData(); ResultMap resultMaps = MybatisUtils.getResultMap(resultMapId); rdbTableMetaData.setName(tableName); rdbTableMetaData.setDatabaseMetaData(active); List<ResultMapping> resultMappings = new ArrayList<>(resultMaps.getResultMappings()); resultMappings.addAll(resultMaps.getIdResultMappings()); resultMappings.forEach(resultMapping -> { if (resultMapping.getNestedQueryId() == null) { RDBColumnMetaData column = new RDBColumnMetaData(); column.setJdbcType(JDBCType.valueOf(resultMapping.getJdbcType().name())); column.setName(resultMapping.getColumn()); if (!StringUtils.isNullOrEmpty(resultMapping.getProperty())) { column.setAlias(resultMapping.getProperty()); } column.setJavaType(resultMapping.getJavaType()); column.setProperty("resultMapping", resultMapping); ValueConverter dateConvert = new DateTimeConverter("yyyy-MM-dd HH:mm:ss", column.getJavaType()) { @Override public Object getData(Object value) { if (value instanceof Number) { return new Date(((Number) value).longValue()); } return super.getData(value); } }; if (column.getJdbcType() == JDBCType.DATE) { column.setValueConverter(dateConvert); } else if (column.getJdbcType() == JDBCType.TIMESTAMP) { column.setValueConverter(dateConvert); } else if (column.getJdbcType() == JDBCType.NUMERIC) { column.setValueConverter(new NumberValueConverter(column.getJavaType())); } rdbTableMetaData.addColumn(column); } }); cache.put(cacheKey, rdbTableMetaData); if (useJpa) { Class type = entityFactory == null ? resultMaps.getType() : entityFactory.getInstanceType(resultMaps.getType()); RDBTableMetaData parseResult = JpaAnnotationParser.parseMetaDataFromEntity(type); if (parseResult != null) { for (RDBColumnMetaData columnMetaData : parseResult.getColumns()) { if (rdbTableMetaData.findColumn(columnMetaData.getName()) == null) { columnMetaData = columnMetaData.clone(); columnMetaData.setProperty("fromJpa", true); rdbTableMetaData.addColumn(columnMetaData); } } } } return rdbTableMetaData; }