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:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void update(final Standplaats origineel, final Standplaats mutation) throws DAOException { try {//from www .j a va 2s .c o m transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement("update bag_standplaats set" + " aanduiding_record_inactief = ?," + " aanduiding_record_correctie = ?," + " officieel = ?," + " standplaats_status = ?," + " standplaats_geometrie = ?," + " einddatum_tijdvak_geldigheid = ?," + " in_onderzoek = ?," + " bron_documentdatum = ?," + " bron_documentnummer = ?," + " bag_nummeraanduiding_id = ?" + " where bag_standplaats_id = ?" + " and aanduiding_record_correctie = ?" + " and begindatum_tijdvak_geldigheid = ?"); ps.setInt(1, mutation.getAanduidingRecordInactief().ordinal()); ps.setLong(2, mutation.getAanduidingRecordCorrectie()); ps.setInt(3, mutation.getOfficieel().ordinal()); ps.setInt(4, mutation.getStandplaatsStatus().ordinal()); ps.setString(5, mutation.getStandplaatsGeometrie()); if (mutation.getEinddatumTijdvakGeldigheid() == null) ps.setNull(6, Types.TIMESTAMP); else ps.setTimestamp(6, new Timestamp(mutation.getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(7, mutation.getInOnderzoek().ordinal()); ps.setDate(8, new Date(mutation.getDocumentdatum().getTime())); ps.setString(9, mutation.getDocumentnummer()); ps.setLong(10, mutation.getHoofdAdres()); ps.setLong(11, origineel.getIdentificatie()); ps.setLong(12, origineel.getAanduidingRecordCorrectie()); ps.setTimestamp(13, new Timestamp(origineel.getBegindatumTijdvakGeldigheid().getTime())); return ps; } }); deleteNevenadressen(TypeAdresseerbaarObject.STANDPLAATS, origineel); insertNevenadressen(TypeAdresseerbaarObject.STANDPLAATS, mutation); } }); } catch (DataAccessException e) { throw new DAOException("Error updating standplaats: " + origineel.getIdentificatie(), e); } }
From source file:lasige.steeldb.jdbc.BFTRowSet.java
/** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Date</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value as a <code>java.sql.Data</code> object; if * the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails *///from w ww . j a v a2 s .com public java.sql.Date getDate(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it, a timestamp * we turn into a long and then into a date, * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.DATE: { long sec = ((java.sql.Date) value).getTime(); return new java.sql.Date(sec); } case java.sql.Types.TIMESTAMP: { long sec = ((java.sql.Timestamp) value).getTime(); return new java.sql.Date(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { java.util.Date parsedDate = parseDate(columnIndex, value); return new java.sql.Date(parsedDate.getTime()); } default: { throw new SQLException( MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.datefail").toString(), new Object[] { value.toString().trim(), columnIndex })); } } }
From source file:lasige.steeldb.jdbc.BFTRowSet.java
/** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Time</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails *///from w w w. j a va 2 s .c om public java.sql.Time getTime(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it, a timestamp * we turn into a long and then into a date, * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.TIME: { return (java.sql.Time) value; } case java.sql.Types.TIMESTAMP: { long sec = ((java.sql.Timestamp) value).getTime(); return new java.sql.Time(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { java.util.Date parsedDate = parseDate(columnIndex, value); return new java.sql.Time(parsedDate.getTime()); } default: { throw new SQLException( MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] { value.toString().trim(), columnIndex })); } } }
From source file:lasige.steeldb.jdbc.BFTRowSet.java
/** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Timestamp</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails *///from w w w . j a v a 2s .com public java.sql.Timestamp getTimestamp(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it; a timestamp * we turn into a long and then into a date; * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.TIMESTAMP: { return (java.sql.Timestamp) value; } case java.sql.Types.TIME: { long sec = ((java.sql.Time) value).getTime(); return new java.sql.Timestamp(sec); } case java.sql.Types.DATE: { long sec = ((java.sql.Date) value).getTime(); return new java.sql.Timestamp(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { java.util.Date parsedDate = parseDate(columnIndex, value); return new Timestamp(parsedDate.getTime()); } default: { throw new SQLException( MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] { value.toString().trim(), columnIndex })); } } }
From source file:org.apache.ddlutils.platform.PlatformImplBase.java
/** * This is the core method to retrieve a value for a column from a result set. Its primary * purpose is to call the appropriate method on the result set, and to provide an extension * point where database-specific implementations can change this behavior. * /* ww w . j a v a 2s . c o m*/ * @param resultSet The result set to extract the value from * @param columnName The name of the column; can be <code>null</code> in which case the * <code>columnIdx</code> will be used instead * @param columnIdx The index of the column's value in the result set; is only used if * <code>columnName</code> is <code>null</code> * @param jdbcType The jdbc type to extract * @return The value * @throws SQLException If an error occurred while accessing the result set */ protected Object extractColumnValue(ResultSet resultSet, String columnName, int columnIdx, int jdbcType) throws SQLException { boolean useIdx = (columnName == null); Object value; switch (jdbcType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: value = useIdx ? resultSet.getString(columnIdx) : resultSet.getString(columnName); break; case Types.NUMERIC: case Types.DECIMAL: value = useIdx ? resultSet.getBigDecimal(columnIdx) : resultSet.getBigDecimal(columnName); break; case Types.BIT: case Types.BOOLEAN: value = new Boolean(useIdx ? resultSet.getBoolean(columnIdx) : resultSet.getBoolean(columnName)); break; case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: value = new Integer(useIdx ? resultSet.getInt(columnIdx) : resultSet.getInt(columnName)); break; case Types.BIGINT: value = new Long(useIdx ? resultSet.getLong(columnIdx) : resultSet.getLong(columnName)); break; case Types.REAL: value = new Float(useIdx ? resultSet.getFloat(columnIdx) : resultSet.getFloat(columnName)); break; case Types.FLOAT: case Types.DOUBLE: value = new Double(useIdx ? resultSet.getDouble(columnIdx) : resultSet.getDouble(columnName)); break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: value = useIdx ? resultSet.getBytes(columnIdx) : resultSet.getBytes(columnName); break; case Types.DATE: value = useIdx ? resultSet.getDate(columnIdx) : resultSet.getDate(columnName); break; case Types.TIME: value = useIdx ? resultSet.getTime(columnIdx) : resultSet.getTime(columnName); break; case Types.TIMESTAMP: value = useIdx ? resultSet.getTimestamp(columnIdx) : resultSet.getTimestamp(columnName); break; case Types.CLOB: Clob clob = useIdx ? resultSet.getClob(columnIdx) : resultSet.getClob(columnName); if (clob == null) { value = null; } else { long length = clob.length(); if (length > Integer.MAX_VALUE) { value = clob; } else if (length == 0) { // the javadoc is not clear about whether Clob.getSubString // can be used with a substring length of 0 // thus we do the safe thing and handle it ourselves value = ""; } else { value = clob.getSubString(1l, (int) length); } } break; case Types.BLOB: Blob blob = useIdx ? resultSet.getBlob(columnIdx) : resultSet.getBlob(columnName); if (blob == null) { value = null; } else { long length = blob.length(); if (length > Integer.MAX_VALUE) { value = blob; } else if (length == 0) { // the javadoc is not clear about whether Blob.getBytes // can be used with for 0 bytes to be copied // thus we do the safe thing and handle it ourselves value = new byte[0]; } else { value = blob.getBytes(1l, (int) length); } } break; case Types.ARRAY: value = useIdx ? resultSet.getArray(columnIdx) : resultSet.getArray(columnName); break; case Types.REF: value = useIdx ? resultSet.getRef(columnIdx) : resultSet.getRef(columnName); break; default: value = useIdx ? resultSet.getObject(columnIdx) : resultSet.getObject(columnName); break; } return resultSet.wasNull() ? null : value; }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void delete(final Woonplaats woonplaats) { try {//w w w . j a v a 2 s. c o m jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement("delete from bag_woonplaats" + " where bag_woonplaats_id = ?" + " and aanduiding_record_correctie = ?" + " and begindatum_tijdvak_geldigheid = ?" + " and einddatum_tijdvak_geldigheid = ?"); ps.setLong(1, woonplaats.getIdentificatie()); ps.setLong(2, woonplaats.getAanduidingRecordCorrectie()); ps.setTimestamp(3, new Timestamp(woonplaats.getBegindatumTijdvakGeldigheid().getTime())); if (woonplaats.getEinddatumTijdvakGeldigheid() == null) ps.setNull(4, Types.TIMESTAMP); else ps.setTimestamp(4, new Timestamp(woonplaats.getEinddatumTijdvakGeldigheid().getTime())); return ps; } }); } catch (DataAccessException e) { throw new DAOException(e); } }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void delete(final OpenbareRuimte openbareRuimte) { try {// w ww.j a va 2 s . co m jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement("delete from bag_openbare_ruimte" + " where bag_openbare_ruimte_id = ?" + " and aanduiding_record_correctie = ?" + " and begindatum_tijdvak_geldigheid = ?" + " and einddatum_tijdvak_geldigheid = ?"); ps.setLong(1, openbareRuimte.getIdentificatie()); ps.setLong(2, openbareRuimte.getAanduidingRecordCorrectie()); ps.setTimestamp(3, new Timestamp(openbareRuimte.getBegindatumTijdvakGeldigheid().getTime())); if (openbareRuimte.getEinddatumTijdvakGeldigheid() == null) ps.setNull(4, Types.TIMESTAMP); else ps.setTimestamp(4, new Timestamp(openbareRuimte.getEinddatumTijdvakGeldigheid().getTime())); return ps; } }); } catch (DataAccessException e) { throw new DAOException(e); } }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void delete(final Nummeraanduiding nummeraanduiding) { try {// w ww.j a v a2 s . c o m jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement("delete from bag_nummeraanduiding" + " where bag_nummeraanduiding_id = ?" + " and aanduiding_record_correctie = ?" + " and begindatum_tijdvak_geldigheid = ?" + " and einddatum_tijdvak_geldigheid = ?"); ps.setLong(1, nummeraanduiding.getIdentificatie()); ps.setLong(2, nummeraanduiding.getAanduidingRecordCorrectie()); ps.setTimestamp(3, new Timestamp(nummeraanduiding.getBegindatumTijdvakGeldigheid().getTime())); if (nummeraanduiding.getEinddatumTijdvakGeldigheid() == null) ps.setNull(4, Types.TIMESTAMP); else ps.setTimestamp(4, new Timestamp(nummeraanduiding.getEinddatumTijdvakGeldigheid().getTime())); return ps; } }); } catch (DataAccessException e) { throw new DAOException(e); } }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void delete(final Verblijfsobject verblijfsobject) { try {//from ww w. ja v a 2 s. com deleteGebruikersdoelen(verblijfsobject); deleteNevenadressen(TypeAdresseerbaarObject.VERBLIJFSOBJECT, verblijfsobject); deleteGerelateerdePanden(verblijfsobject); jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement("delete from bag_verblijfsobject" + " where bag_verblijfsobject_id = ?" + " and aanduiding_record_correctie = ?" + " and begindatum_tijdvak_geldigheid = ?" + " and einddatum_tijdvak_geldigheid = ?"); ps.setLong(1, verblijfsobject.getIdentificatie()); ps.setLong(2, verblijfsobject.getAanduidingRecordCorrectie()); ps.setTimestamp(3, new Timestamp(verblijfsobject.getBegindatumTijdvakGeldigheid().getTime())); if (verblijfsobject.getEinddatumTijdvakGeldigheid() == null) ps.setNull(4, Types.TIMESTAMP); else ps.setTimestamp(4, new Timestamp(verblijfsobject.getEinddatumTijdvakGeldigheid().getTime())); return ps; } }); } catch (DataAccessException e) { throw new DAOException(e); } }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void delete(final Pand pand) { try {//w w w . j a v a2 s .c o m jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement("delete from bag_pand" + " where bag_pand_id = ?" + " and aanduiding_record_correctie = ?" + " and begindatum_tijdvak_geldigheid = ?" + " and einddatum_tijdvak_geldigheid = ?"); ps.setLong(1, pand.getIdentificatie()); ps.setLong(2, pand.getAanduidingRecordCorrectie()); ps.setTimestamp(3, new Timestamp(pand.getBegindatumTijdvakGeldigheid().getTime())); if (pand.getEinddatumTijdvakGeldigheid() == null) ps.setNull(4, Types.TIMESTAMP); else ps.setTimestamp(4, new Timestamp(pand.getEinddatumTijdvakGeldigheid().getTime())); return ps; } }); } catch (DataAccessException e) { throw new DAOException(e); } }