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.apache.sqoop.mapreduce.hcat.SqoopHCatUtilities.java
/** * Resolve a database-specific type to HCat data type. Largely follows Sqoop's * hive translation./*from w ww. ja va2 s .co m*/ * @param sqlType * sql type * @return hcat type */ public static String toHCatType(int sqlType) { switch (sqlType) { // Ideally TINYINT and SMALLINT should be mapped to their // HCat equivalents tinyint and smallint respectively // But the Sqoop Java type conversion has them mapped to Integer // Even though the referenced Java doc clearly recommends otherwise. // Changing this now can cause many of the sequence file usages to // break as value class implementations will change. So, we // just use the same behavior here. case Types.SMALLINT: case Types.TINYINT: case Types.INTEGER: return "int"; case Types.VARCHAR: return "varchar"; case Types.CHAR: return "char"; case Types.LONGVARCHAR: case Types.NVARCHAR: case Types.NCHAR: case Types.LONGNVARCHAR: case Types.DATE: case Types.TIME: case Types.TIMESTAMP: case Types.CLOB: return "string"; case Types.FLOAT: case Types.REAL: return "float"; case Types.NUMERIC: case Types.DECIMAL: return "decimal"; case Types.DOUBLE: return "double"; case Types.BIT: case Types.BOOLEAN: return "boolean"; case Types.BIGINT: return "bigint"; case Types.BINARY: case Types.VARBINARY: case Types.BLOB: case Types.LONGVARBINARY: return "binary"; default: throw new IllegalArgumentException("Cannot convert SQL type to HCatalog type " + sqlType); } }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insertPanden(final List<Pand> panden) throws DAOException { try {//from w ww. jav a2s .c om jdbcTemplate.batchUpdate("insert into bag_pand (" + "bag_pand_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "officieel," + "pand_geometrie," + "bouwjaar," + "pand_status," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer" + ") values (?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setLong(1, panden.get(i).getIdentificatie()); ps.setInt(2, panden.get(i).getAanduidingRecordInactief().ordinal()); ps.setLong(3, panden.get(i).getAanduidingRecordCorrectie()); ps.setInt(4, panden.get(i).getOfficieel().ordinal()); ps.setString(5, panden.get(i).getPandGeometrie()); ps.setInt(6, panden.get(i).getBouwjaar()); ps.setString(7, panden.get(i).getPandStatus()); ps.setTimestamp(8, new Timestamp(panden.get(i).getBegindatumTijdvakGeldigheid().getTime())); if (panden.get(i).getEinddatumTijdvakGeldigheid() == null) ps.setNull(9, Types.TIMESTAMP); else ps.setTimestamp(9, new Timestamp(panden.get(i).getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(10, panden.get(i).getInOnderzoek().ordinal()); ps.setDate(11, new Date(panden.get(i).getDocumentdatum().getTime())); ps.setString(12, panden.get(i).getDocumentnummer()); } @Override public int getBatchSize() { return panden.size(); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting panden", e); } }
From source file:org.easyrec.store.dao.core.impl.ItemAssocDAOMysqlImpl.java
@Override public int removeItemAssocsQBE(ItemAssocVO<Integer, Integer> itemAssoc) { // validate input parameters validateOneAttributeSet(itemAssoc);//from w w w . j av a 2 s .c o m if (logger.isDebugEnabled()) { logger.debug("removing 'itemAssoc' that match the following Example '" + itemAssoc + "'"); } StringBuilder sqlString = new StringBuilder("DELETE FROM "); sqlString.append(DEFAULT_TABLE_NAME); sqlString.append(" WHERE "); List<Object> args = Lists.newArrayList(); List<Integer> argt = Lists.newArrayList(); // add constraints to the query if (itemAssoc.getId() != null) { sqlString.append(DEFAULT_ID_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getId()); argt.add(Types.INTEGER); } if (itemAssoc.getTenant() != null) { sqlString.append(DEFAULT_TENANT_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getTenant()); argt.add(Types.INTEGER); } if (itemAssoc.getItemFrom() != null) { ItemVO<Integer, Integer> itemFrom = itemAssoc.getItemFrom(); if (itemFrom.getItem() != null) { sqlString.append(DEFAULT_ITEM_FROM_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemFrom.getItem()); argt.add(Types.INTEGER); } if (itemFrom.getType() != null) { sqlString.append(DEFAULT_ITEM_FROM_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemFrom.getType()); argt.add(Types.INTEGER); } } if (itemAssoc.getAssocType() != null) { sqlString.append(DEFAULT_ASSOC_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getAssocType()); argt.add(Types.INTEGER); } if (itemAssoc.getAssocValue() != null) { sqlString.append(DEFAULT_ASSOC_VALUE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getAssocValue()); argt.add(Types.DOUBLE); } if (itemAssoc.getItemTo() != null) { ItemVO<Integer, Integer> itemTo = itemAssoc.getItemTo(); if (itemTo.getItem() != null) { sqlString.append(DEFAULT_ITEM_TO_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemTo.getItem()); argt.add(Types.INTEGER); } if (itemTo.getType() != null) { sqlString.append(DEFAULT_ITEM_TO_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemTo.getType()); argt.add(Types.INTEGER); } } if (itemAssoc.getSourceType() != null) { sqlString.append(DEFAULT_SOURCE_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getSourceType()); argt.add(Types.INTEGER); } if (itemAssoc.getSourceInfo() != null) { sqlString.append(DEFAULT_SOURCE_INFO_COLUMN_NAME); sqlString.append(" LIKE ? AND "); args.add(itemAssoc.getSourceInfo()); argt.add(Types.VARCHAR); } if (itemAssoc.getViewType() != null) { sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getViewType()); argt.add(Types.INTEGER); } if (itemAssoc.isActive() != null) { sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.isActive()); argt.add(Types.BOOLEAN); } if (itemAssoc.getChangeDate() != null) { sqlString.append("changeDate"); sqlString.append("=? AND "); args.add(itemAssoc.getChangeDate()); argt.add(Types.TIMESTAMP); } // remove trailing " AND " sqlString.delete(sqlString.length() - 5, sqlString.length()); return getJdbcTemplate().update(sqlString.toString(), args.toArray(), Ints.toArray(argt)); }
From source file:org.jumpmind.symmetric.db.AbstractTriggerTemplate.java
protected String buildKeyVariablesDeclare(Column[] columns, String prefix) { String text = ""; for (int i = 0; i < columns.length; i++) { text += "declare @" + prefix + "pk" + i + " "; switch (columns[i].getMappedTypeCode()) { case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: text += "bigint\n"; break; case Types.NUMERIC: case Types.DECIMAL: text += "decimal\n"; break; case Types.FLOAT: case Types.REAL: case Types.DOUBLE: text += "float\n"; break; case Types.CHAR: case Types.VARCHAR: case ColumnTypes.NVARCHAR: case ColumnTypes.LONGNVARCHAR: case Types.LONGVARCHAR: text += "varchar(1000)\n"; break; case Types.DATE: text += "date\n"; break; case Types.TIME: text += "time\n"; break; case Types.TIMESTAMP: text += "datetime\n"; break; case Types.BOOLEAN: case Types.BIT: text += "bit\n"; break; case Types.CLOB: text += "varchar(max)\n"; break; case Types.BLOB: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case -10: // SQL-Server ntext binary type text += "varbinary(max)\n"; break; case Types.OTHER: text += "varbinary(max)\n"; break; default:// w w w.j a va2 s. c om if (columns[i].getJdbcTypeName() != null && columns[i].getJdbcTypeName().equalsIgnoreCase("interval")) { text += "interval"; break; } throw new NotImplementedException(columns[i] + " is of type " + columns[i].getMappedType()); } } return text; }
From source file:org.siphon.jssql.SqlExecutor.java
private Object translateOutputParameterValue(int sqlType, CallableStatement cs, int index) throws SQLException, SqlExecutorException, ScriptException { Object obj = cs.getObject(index); if (obj == null) { return null; } else {/*from ww w. ja va 2s . c o m*/ switch (sqlType) { case Types.DATE: obj = cs.getDate(index); case Types.TIME: obj = cs.getTime(index); case Types.TIMESTAMP: obj = cs.getTimestamp(index); } } Object result = jdbcReturnTypeToJsObject(obj); if (result instanceof String) { return ((String) result).trim(); } else { return result; } }
From source file:org.easyrec.store.dao.core.impl.ItemAssocDAOMysqlImpl.java
@Override public int removeItemAssocByTenant(Integer tenantId, Integer assocType, Integer sourceType, Date changeDate) { if (tenantId == null) { throw new IllegalArgumentException("missing 'tenantId'"); }// w w w .ja v a 2 s .c om if (logger.isDebugEnabled()) { logger.debug("removing 'itemAssocs' for tenant " + tenantId); } StringBuilder sqlString = new StringBuilder("DELETE FROM "); sqlString.append(DEFAULT_TABLE_NAME); sqlString.append(" WHERE "); List<Object> args = Lists.newArrayList(); List<Integer> argt = Lists.newArrayList(); // add constraints to the query sqlString.append(DEFAULT_TENANT_COLUMN_NAME); sqlString.append("=?"); args.add(tenantId); argt.add(Types.INTEGER); if (assocType != null) { sqlString.append(" AND ").append(DEFAULT_ASSOC_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(assocType); argt.add(Types.INTEGER); } if (sourceType != null) { sqlString.append(" AND ").append(DEFAULT_SOURCE_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(sourceType); argt.add(Types.INTEGER); } if (changeDate != null) { sqlString.append(" AND ").append(DEFAULT_CHANGE_DATE_COLUMN_NAME); sqlString.append("<?"); args.add(changeDate); argt.add(Types.TIMESTAMP); } return getJdbcTemplate().update(sqlString.toString(), args.toArray(), Ints.toArray(argt)); }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insertVerblijfsobjecten(final List<Verblijfsobject> verblijfsobjecten) throws DAOException { try {/*from w w w . ja v a 2 s.c o m*/ transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { jdbcTemplate.batchUpdate("insert into bag_verblijfsobject (" + "bag_verblijfsobject_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "officieel," + "verblijfsobject_geometrie," + "oppervlakte_verblijfsobject," + "verblijfsobject_status," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer," + "bag_nummeraanduiding_id" + ") values (?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setLong(1, verblijfsobjecten.get(i).getIdentificatie()); ps.setInt(2, verblijfsobjecten.get(i).getAanduidingRecordInactief().ordinal()); ps.setLong(3, verblijfsobjecten.get(i).getAanduidingRecordCorrectie()); ps.setInt(4, verblijfsobjecten.get(i).getOfficieel().ordinal()); ps.setString(5, verblijfsobjecten.get(i).getVerblijfsobjectGeometrie()); ps.setInt(6, verblijfsobjecten.get(i).getOppervlakteVerblijfsobject()); ps.setInt(7, verblijfsobjecten.get(i).getVerblijfsobjectStatus().ordinal()); ps.setTimestamp(8, new Timestamp( verblijfsobjecten.get(i).getBegindatumTijdvakGeldigheid().getTime())); if (verblijfsobjecten.get(i).getEinddatumTijdvakGeldigheid() == null) ps.setNull(9, Types.TIMESTAMP); else ps.setTimestamp(9, new Timestamp(verblijfsobjecten.get(i) .getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(10, verblijfsobjecten.get(i).getInOnderzoek().ordinal()); ps.setDate(11, new Date(verblijfsobjecten.get(i).getDocumentdatum().getTime())); ps.setString(12, verblijfsobjecten.get(i).getDocumentnummer()); ps.setLong(13, verblijfsobjecten.get(i).getHoofdAdres()); } @Override public int getBatchSize() { return verblijfsobjecten.size(); } }); insertGebruikersdoelen(verblijfsobjecten); insertNevenadressen(TypeAdresseerbaarObject.VERBLIJFSOBJECT, verblijfsobjecten); insertGerelateerdePanden(verblijfsobjecten); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting verblijfsobjecten", e); } }
From source file:com.mirth.connect.donkey.test.util.TestUtils.java
private static String typeToString(int sqlType) { switch (sqlType) { case Types.ARRAY: return "ARRAY"; case Types.BIGINT: return "BIGINT"; case Types.BINARY: return "BINARY"; case Types.BIT: return "BIT"; case Types.BLOB: return "BLOB"; case Types.BOOLEAN: return "BOOLEAN"; case Types.CHAR: return "CHAR"; case Types.CLOB: return "CLOB"; case Types.DATALINK: return "DATALINK"; case Types.DATE: return "DATE"; case Types.DECIMAL: return "DECIMAL"; case Types.DISTINCT: return "DISTINCT"; case Types.DOUBLE: return "DOUBLE"; case Types.FLOAT: return "FLOAT"; case Types.INTEGER: return "INTEGER"; case Types.JAVA_OBJECT: return "JAVA_OBJECT"; case Types.LONGNVARCHAR: return "LONGNVARCHAR"; case Types.LONGVARBINARY: return "LONGVARBINARY"; case Types.LONGVARCHAR: return "LONGVARCHAR"; case Types.NCHAR: return "NCHAR"; case Types.NCLOB: return "NCLOB"; case Types.NULL: return "NULL"; case Types.NUMERIC: return "NUMERIC"; case Types.NVARCHAR: return "NVARCHAR"; case Types.OTHER: return "OTHER"; case Types.REAL: return "REAL"; case Types.REF: return "REF"; case Types.ROWID: return "ROWID"; case Types.SMALLINT: return "SMALLINT"; case Types.SQLXML: return "SQLXML"; case Types.STRUCT: return "STRUCT"; case Types.TIME: return "TIME"; case Types.TIMESTAMP: return "TIMESTAMP"; case Types.TINYINT: return "TINYINT"; case Types.VARBINARY: return "VARBINARY"; case Types.VARCHAR: return "VARCHAR"; default://from w w w . j ava2s .c om return "UNKNOWN"; } }
From source file:org.jumpmind.symmetric.service.impl.TriggerRouterService.java
public void insert(TriggerHistory newHistRecord) { newHistRecord.setTriggerHistoryId((int) sequenceService.nextVal(Constants.SEQUENCE_TRIGGER_HIST)); historyMap.put(newHistRecord.getTriggerHistoryId(), newHistRecord); sqlTemplate.update(getSql("insertTriggerHistorySql"), new Object[] { newHistRecord.getTriggerHistoryId(), newHistRecord.getTriggerId(), newHistRecord.getSourceTableName(), newHistRecord.getTableHash(), newHistRecord.getCreateTime(), newHistRecord.getColumnNames(), newHistRecord.getPkColumnNames(), newHistRecord.getLastTriggerBuildReason().getCode(), newHistRecord.getNameForDeleteTrigger(), newHistRecord.getNameForInsertTrigger(), newHistRecord.getNameForUpdateTrigger(), newHistRecord.getSourceSchemaName(), newHistRecord.getSourceCatalogName(), newHistRecord.getTriggerRowHash(), newHistRecord.getTriggerTemplateHash(), newHistRecord.getErrorMessage() }, new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR, Types.CHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BIGINT, Types.BIGINT, Types.VARCHAR }); }
From source file:org.easyrec.store.dao.core.impl.ItemAssocDAOMysqlImpl.java
@Override public int removeItemAssocByTenantAndThreshold(Integer tenantId, Integer assocType, Integer sourceType, Date changeDate, double threshold) { if (tenantId == null) { throw new IllegalArgumentException("missing 'tenantId'"); }//from w ww.ja v a 2s . co m if (logger.isDebugEnabled()) { logger.debug("removing 'itemAssocs' for tenant " + tenantId); } StringBuilder sqlString = new StringBuilder("DELETE FROM "); sqlString.append(DEFAULT_TABLE_NAME); sqlString.append(" WHERE "); List<Object> args = Lists.newArrayList(); List<Integer> argt = Lists.newArrayList(); // add constraints to the query sqlString.append(DEFAULT_TENANT_COLUMN_NAME); sqlString.append("=?"); args.add(tenantId); argt.add(Types.INTEGER); if (assocType != null) { sqlString.append(" AND ").append(DEFAULT_ASSOC_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(assocType); argt.add(Types.INTEGER); } if (sourceType != null) { sqlString.append(" AND ").append(DEFAULT_SOURCE_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(sourceType); argt.add(Types.INTEGER); } if (changeDate != null) { sqlString.append(" AND ").append(DEFAULT_CHANGE_DATE_COLUMN_NAME); sqlString.append("<?"); args.add(changeDate); argt.add(Types.TIMESTAMP); } sqlString.append(" AND ").append(DEFAULT_ASSOC_VALUE_COLUMN_NAME); sqlString.append("<?"); args.add(threshold); argt.add(Types.DOUBLE); return getJdbcTemplate().update(sqlString.toString(), args.toArray(), Ints.toArray(argt)); }