List of usage examples for java.sql Types TIMESTAMP
int TIMESTAMP
To view the source code for java.sql Types TIMESTAMP.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIMESTAMP
.
From source file:org.easyrec.plugin.aggregator.store.dao.impl.AggregatorActionDAOMysqlImpl.java
@Override public List<Integer> getUsersWithActions(AggregatorConfigurationInt configuration) { //Todo: only get non-anonymous users! -> done using idMappingDAO later //Todo: move to iterator List<Object> args = Lists.newArrayList(); List<Integer> argt = Lists.newArrayList(); // get all Baskets StringBuilder query = new StringBuilder(); query.append("SELECT DISTINCT(a.").append(BaseActionDAO.DEFAULT_USER_COLUMN_NAME); query.append(") FROM ").append(BaseActionDAO.DEFAULT_TABLE_NAME).append(" a, idmapping i"); query.append(" WHERE ").append(BaseActionDAO.DEFAULT_TENANT_COLUMN_NAME).append("=") .append(configuration.getTenantId()); if (configuration.getActionType() != null) { query.append(" AND ").append(BaseActionDAO.DEFAULT_ACTION_TYPE_COLUMN_NAME).append("=?"); args.add(configuration.getActionType()); argt.add(Types.INTEGER);/*w ww . j a va 2 s . co m*/ } if (configuration.getLastRun() != null) { query.append(" AND ").append(BaseActionDAO.DEFAULT_ACTION_TIME_COLUMN_NAME).append(">=?"); args.add(configuration.getLastRun()); argt.add(Types.TIMESTAMP); } // filter anonymous users query.append(" AND a.userId=i.intId AND a.sessionId!=i.stringId"); List<Integer> baskets = getJdbcTemplate().queryForList(query.toString(), args.toArray(), Ints.toArray(argt), Integer.class); return baskets; }
From source file:org.jumpmind.db.platform.oracle.OracleDdlReader.java
@Override protected Integer mapUnknownJdbcTypeForColumn(Map<String, Object> values) { String typeName = (String) values.get("TYPE_NAME"); if (typeName != null && typeName.startsWith("DATE")) { return Types.DATE; } else if (typeName != null && typeName.startsWith("TIMESTAMP") && !typeName.endsWith("TIME ZONE")) { // This is for Oracle's TIMESTAMP(9) return Types.TIMESTAMP; } else if (typeName != null && typeName.startsWith("TIMESTAMP") && typeName.endsWith("WITH TIME ZONE")) { return ColumnTypes.ORACLE_TIMESTAMPTZ; } else if (typeName != null && typeName.startsWith("TIMESTAMP") && typeName.endsWith("WITH LOCAL TIME ZONE")) { return ColumnTypes.ORACLE_TIMESTAMPLTZ; } else if (typeName != null && typeName.startsWith("NVARCHAR")) { // This is for Oracle's NVARCHAR type return Types.VARCHAR; } else if (typeName != null && typeName.startsWith("LONGNVARCHAR")) { return Types.LONGVARCHAR; } else if (typeName != null && typeName.startsWith("NCHAR")) { return Types.CHAR; } else if (typeName != null && typeName.startsWith("XML")) { return Types.LONGVARCHAR; } else if (typeName != null && typeName.endsWith("CLOB")) { return Types.LONGVARCHAR; } else if (typeName != null && typeName.startsWith("BINARY_FLOAT")) { return Types.FLOAT; } else if (typeName != null && typeName.startsWith("BINARY_DOUBLE")) { return Types.DOUBLE; } else if (typeName != null && typeName.startsWith("BFILE")) { return Types.VARCHAR; } else {//from ww w . jav a2 s.c o m return super.mapUnknownJdbcTypeForColumn(values); } }
From source file:org.nuxeo.ecm.core.storage.sql.db.dialect.DialectPostgreSQL.java
@Override public JDBCInfo getJDBCTypeAndString(ColumnType type) { switch (type) { case VARCHAR: return jdbcInfo("varchar", Types.VARCHAR); case CLOB:/*from w w w . j ava 2s. c o m*/ return jdbcInfo("text", Types.CLOB); case BOOLEAN: return jdbcInfo("bool", Types.BIT); case LONG: return jdbcInfo("int8", Types.BIGINT); case DOUBLE: return jdbcInfo("float8", Types.DOUBLE); case TIMESTAMP: return jdbcInfo("timestamp", Types.TIMESTAMP); case BLOBID: return jdbcInfo("varchar(40)", Types.VARCHAR); // ----- case NODEID: case NODEIDFK: case NODEIDFKNP: case NODEIDFKMUL: case NODEIDFKNULL: case NODEVAL: return jdbcInfo("varchar(36)", Types.VARCHAR); case SYSNAME: return jdbcInfo("varchar(250)", Types.VARCHAR); case TINYINT: return jdbcInfo("int2", Types.SMALLINT); case INTEGER: return jdbcInfo("int4", Types.INTEGER); case FTINDEXED: return jdbcInfo("tsvector", Types.OTHER); case FTSTORED: return jdbcInfo("tsvector", Types.OTHER); case CLUSTERNODE: return jdbcInfo("int4", Types.INTEGER); case CLUSTERFRAGS: return jdbcInfo("varchar[]", Types.ARRAY); } throw new AssertionError(type); }
From source file:architecture.ee.web.community.profile.dao.jdbc.JdbcProfileDao.java
public void addProfileImage(ProfileImage image, File file) { try {/* w w w . j ava2s .c o m*/ ProfileImage toUse = image; if (toUse.getProfileImageId() < 1L) { long imageId = getNextId(sequencerName); if (image instanceof DefaultProfileImage) { DefaultProfileImage impl = (DefaultProfileImage) toUse; impl.setProfileImageId(imageId); } } else { Date now = Calendar.getInstance().getTime(); toUse.setModifiedDate(now); } if (toUse.getImageSize() == 0) toUse.setImageSize((int) FileUtils.sizeOf(file)); getExtendedJdbcTemplate().update( getBoundSql("ARCHITECTURE_COMMUNITY.RESET_PROFILE_IMAGE_BY_USER").getSql(), new SqlParameterValue(Types.INTEGER, toUse.getUserId())); getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_COMMUNITY.INSERT_PROFILE_IMAGE").getSql(), new SqlParameterValue(Types.NUMERIC, toUse.getProfileImageId()), new SqlParameterValue(Types.INTEGER, toUse.getUserId()), new SqlParameterValue(Types.VARCHAR, toUse.getFilename()), new SqlParameterValue(Types.INTEGER, toUse.getImageSize()), new SqlParameterValue(Types.VARCHAR, toUse.getImageContentType()), new SqlParameterValue(Types.TIMESTAMP, toUse.getCreationDate()), new SqlParameterValue(Types.TIMESTAMP, toUse.getModifiedDate())); updateProfileImageImputStream(image, FileUtils.openInputStream(file)); } catch (IOException e) { } }
From source file:org.springframework.jdbc.core.StatementCreatorUtils.java
/** * Derive a default SQL type from the given Java type. * @param javaType the Java type to translate * @return the corresponding SQL type, or {@link SqlTypeValue#TYPE_UNKNOWN} if none found *///from w w w .ja v a 2s.c o m public static int javaTypeToSqlParameterType(@Nullable Class<?> javaType) { if (javaType == null) { return SqlTypeValue.TYPE_UNKNOWN; } Integer sqlType = javaTypeToSqlTypeMap.get(javaType); if (sqlType != null) { return sqlType; } if (Number.class.isAssignableFrom(javaType)) { return Types.NUMERIC; } if (isStringValue(javaType)) { return Types.VARCHAR; } if (isDateValue(javaType) || Calendar.class.isAssignableFrom(javaType)) { return Types.TIMESTAMP; } return SqlTypeValue.TYPE_UNKNOWN; }
From source file:com.cisco.dvbu.ps.utils.log.GetServerMetadataLog.java
/** * Called during introspection to get the description of the input and * output parameters. Should not return null. *//*www . jav a 2 s . co m*/ public ParameterInfo[] getParameterInfo() { return new ParameterInfo[] { new ParameterInfo("result", TYPED_CURSOR, DIRECTION_OUT, new ParameterInfo[] { new ParameterInfo("change_time", Types.TIMESTAMP, DIRECTION_NONE), new ParameterInfo("cid", Types.INTEGER, DIRECTION_NONE), new ParameterInfo("domain", Types.VARCHAR, DIRECTION_NONE), new ParameterInfo("user", Types.VARCHAR, DIRECTION_NONE), new ParameterInfo("userid", Types.INTEGER, DIRECTION_NONE), new ParameterInfo("hostname", Types.VARCHAR, DIRECTION_NONE), new ParameterInfo("operation", Types.VARCHAR, DIRECTION_NONE), new ParameterInfo("resource_id", Types.INTEGER, DIRECTION_NONE), new ParameterInfo("resource_path", Types.VARCHAR, DIRECTION_NONE), new ParameterInfo("resource_type", Types.VARCHAR, DIRECTION_NONE), new ParameterInfo("message", Types.VARCHAR, DIRECTION_NONE) }) }; }
From source file:konditer.client.dao.CustomerDao.java
@Override public void addCustomer(int customerId, String customerFirstName, String customerDopInfo) { String SQL_QUERY = "INSERT INTO customers ( CUSTOMER_ID, " + "DISCOUNT_ID, " + "CUSTOMER_LAST_NAME, " + "CUSTOMER_FIRST_NAME, " + "CUSTOMER_PARENT_NAME, " + "CUSTOMER_DATE_BORN, " + "CUSTOMER_INFO ) " + "VALUES (?,?,?,?,?,?,?)"; int rowCount = 0; try {//from w ww . j a va2 s . c o m rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { customerId, 1, "", customerFirstName, "", new Date(), customerDopInfo }, new int[] { Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR }); Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE, " : {0} .", rowCount + "\n" + customerDao.getCustomer(customerId).toString()); } catch (DataAccessException e) { rowCount = 0; Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE, " . ?: {0} .", rowCount); } }
From source file:wzw.sql.ResultSetConverter.java
/** * ?/*ww w .j av a 2s . c o m*/ * @param rs * @param type Listjava.sql.Types * @return * @throws SQLException */ public static List<Object> toTypeList(ResultSet rs, int type) throws SQLException { List<Object> list = new ArrayList<Object>(); switch (type) { case Types.INTEGER: while (rs.next()) { list.add(new Integer(rs.getInt(1))); } case Types.BIGINT: while (rs.next()) { list.add(new Long(rs.getLong(1))); } case Types.VARCHAR: while (rs.next()) { list.add(rs.getString(1)); } case Types.FLOAT: while (rs.next()) { list.add(new Float(rs.getFloat(1))); } case Types.DECIMAL: case Types.DOUBLE: case Types.NUMERIC: while (rs.next()) { list.add(new Double(rs.getDouble(1))); } case Types.TIMESTAMP: while (rs.next()) { list.add(rs.getTimestamp(1)); } case Types.DATE: while (rs.next()) { list.add(rs.getDate(1)); } case Types.TIME: while (rs.next()) { list.add(rs.getTime(1)); } //default: } return list; }
From source file:architecture.ee.web.community.page.dao.jdbc.JdbcPageDao.java
/** * ? ?//from w w w .java2s. c o m */ public void create(Page page) { long nextPageId = getNextId(sequencerName); page.setPageId(nextPageId); page.setVersionId(DEFAULT_PAGE_VERSION); // binary body data handleing String tempPrefix = ApplicationHelper.getApplicationProperty("components.page.temporaryPagePrefix", "tempPAGE-"); if (page.getName() == null || page.getName().startsWith(tempPrefix)) { page.setName((new StringBuilder()) .append(ApplicationHelper.getApplicationProperty("components.page.pagePrefix", "PAGE-")) .append(nextPageId).toString()); } // INSERT V2_PAGE getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_COMMUNITY.CREATE_PAGE").getSql(), new SqlParameterValue(Types.NUMERIC, page.getPageId()), new SqlParameterValue(Types.NUMERIC, page.getObjectType()), new SqlParameterValue(Types.NUMERIC, page.getObjectId()), new SqlParameterValue(Types.VARCHAR, page.getName()), new SqlParameterValue(Types.NUMERIC, page.getVersionId()), new SqlParameterValue(Types.NUMERIC, page.getUser().getUserId()), new SqlParameterValue(Types.TIMESTAMP, page.getCreationDate()), new SqlParameterValue(Types.TIMESTAMP, page.getModifiedDate())); insertPageVersion(page); insertPageBody(page); insertProperties(page); }
From source file:org.apache.sqoop.manager.ConnManager.java
/** * Resolve a database-specific type to the Java type that should contain it. * @param sqlType sql type//from w w w.ja v a2 s .c o m * @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; } }