Search in sources :

Example 6 with TimestampData

use of org.hsqldb_voltpatches.types.TimestampData in project voltdb by VoltDB.

the class ValuePoolHashMap method getOrAddDate.

protected TimestampData getOrAddDate(long longKey) {
    TimestampData testValue;
    int hash = (int) longKey ^ (int) (longKey >>> 32);
    int index = hashIndex.getHashIndex(hash);
    int lookup = hashIndex.hashTable[index];
    int lastLookup = -1;
    for (; lookup >= 0; lastLookup = lookup, lookup = hashIndex.getNextLookup(lookup)) {
        testValue = (TimestampData) objectKeyTable[lookup];
        if (testValue.getSeconds() == longKey) {
            if (accessCount == Integer.MAX_VALUE) {
                resetAccessCount();
            }
            accessTable[lookup] = accessCount++;
            return testValue;
        }
    }
    if (hashIndex.elementCount >= threshold) {
        reset();
        return getOrAddDate(longKey);
    }
    lookup = hashIndex.linkNode(index, lastLookup);
    testValue = new TimestampData(longKey);
    objectKeyTable[lookup] = testValue;
    if (accessCount == Integer.MAX_VALUE) {
        resetAccessCount();
    }
    accessTable[lookup] = accessCount++;
    return testValue;
}
Also used : TimestampData(org.hsqldb_voltpatches.types.TimestampData)

Example 7 with TimestampData

use of org.hsqldb_voltpatches.types.TimestampData in project voltdb by VoltDB.

the class JDBCCallableStatement method getTimestamp.

/**
     * <!-- start generic documentation -->
     *
     * Retrieves the value of the designated JDBC <code>TIMESTAMP</code> parameter as a
     * <code>java.sql.Timestamp</code> object, using
     * the given <code>Calendar</code> object to construct
     * the <code>Timestamp</code> object.
     * With a <code>Calendar</code> object, the driver
     * can calculate the timestamp taking into account a custom timezone and locale.
     * If no <code>Calendar</code> object is specified, the driver uses the
     * default timezone and locale.
     *
     * <!-- end generic documentation -->
     *
     * <!-- start release-specific documentation -->
     * <div class="ReleaseSpecificDocumentation">
     * <h3>HSQLDB-Specific Information:</h3> <p>
     *
     * HSQLDB supports this feature. <p>
     *
     * </div>
     * <!-- end release-specific documentation -->
     *
     * @param parameterIndex the first parameter is 1, the second is 2,
     * and so on
     * @param cal the <code>Calendar</code> object the driver will use
     *            to construct the timestamp
     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result
     *         is <code>null</code>.
     * @exception SQLException if a database access error occurs or
     * this method is called on a closed <code>CallableStatement</code>
     * @see #setTimestamp
     * @since JDK 1.2 (JDK 1.1.x developers: read the overview for
     *    JDBCParameterMetaData)
     */
public synchronized Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException {
    TimestampData t = (TimestampData) getColumnInType(parameterIndex, Type.SQL_TIMESTAMP);
    if (t == null) {
        return null;
    }
    long millis = t.getSeconds() * 1000;
    if (parameterTypes[--parameterIndex].isDateTimeTypeWithZone()) {
    } else {
        // UTC - calZO == (UTC - sessZO) + (sessionZO - calZO)
        if (cal != null) {
            int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
            millis += session.getZoneSeconds() * 1000 - zoneOffset;
        }
    }
    Timestamp ts = new Timestamp(millis);
    ts.setNanos(t.getNanos());
    return ts;
}
Also used : TimestampData(org.hsqldb_voltpatches.types.TimestampData) Timestamp(java.sql.Timestamp)

Example 8 with TimestampData

use of org.hsqldb_voltpatches.types.TimestampData in project voltdb by VoltDB.

the class JDBCCallableStatement method getDate.

/**
     * <!-- start generic documentation -->
     *
     * Retrieves the value of the designated JDBC <code>DATE</code> parameter as a
     * <code>java.sql.Date</code> object, using
     * the given <code>Calendar</code> object
     * to construct the date.
     * With a <code>Calendar</code> object, the driver
     * can calculate the date taking into account a custom timezone and locale.
     * If no <code>Calendar</code> object is specified, the driver uses the
     * default timezone and locale.
     *
     * <!-- end generic documentation -->
     *
     * <!-- start release-specific documentation -->
     * <div class="ReleaseSpecificDocumentation">
     * <h3>HSQLDB-Specific Information:</h3> <p>
     *
     * HSQLDB supports this feature. <p>
     *
     * </div>
     * <!-- end release-specific documentation -->
     *
     * @param parameterIndex the first parameter is 1, the second is 2,
     * and so on
     * @param cal the <code>Calendar</code> object the driver will use
     *            to construct the date
     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result
     *         is <code>null</code>.
     * @exception SQLException if a database access error occurs or
     * this method is called on a closed <code>CallableStatement</code>
     * @see #setDate
     * @since JDK 1.2 (JDK 1.1.x developers: read the overview for
     *      JDBCParameterMetaData)
     */
public synchronized Date getDate(int parameterIndex, Calendar cal) throws SQLException {
    TimestampData t = (TimestampData) getColumnInType(parameterIndex, Type.SQL_DATE);
    long millis = t.getSeconds() * 1000;
    int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
    return new Date(millis - zoneOffset);
}
Also used : TimestampData(org.hsqldb_voltpatches.types.TimestampData) Date(java.sql.Date)

Example 9 with TimestampData

use of org.hsqldb_voltpatches.types.TimestampData in project voltdb by VoltDB.

the class JDBCPreparedStatement method setTimestamp.

/**
     * <!-- start generic documentation -->
     * Sets the designated parameter to the given <code>java.sql.Timestamp</code> value,
     * using the given <code>Calendar</code> object.  The driver uses
     * the <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</code> value,
     * which the driver then sends to the database.  With a
     *  <code>Calendar</code> object, the driver can calculate the timestamp
     * taking into account a custom timezone.  If no
     * <code>Calendar</code> object is specified, the driver uses the default
     * timezone, which is that of the virtual machine running the application.
     * <!-- end generic documentation -->
     * <div class="ReleaseSpecificDocumentation">
     * <h3>HSQLDB-Specific Information:</h3> <p>
     *
     * When a setXXX method is used to set a parameter of type
     * TIMESTAMP WITH TIME ZONE or TIME WITH TIME ZONE the time zone (including
     * Daylight Saving Time) of the Calendar is used as time zone.<p>
     *
     * When this method is used to set a parameter of type TIME or
     * TIME WITH TIME ZONE, then the nanosecond value of the Timestamp object
     * is used if the TIME parameter accepts fractional seconds.
     *
     * </div>
     * <!-- end release-specific documentation -->
     *
     * @param parameterIndex the first parameter is 1, the second is 2, ...
     * @param x the parameter value
     * @param cal the <code>Calendar</code> object the driver will use
     *            to construct the timestamp
     * @exception SQLException if a database access error occurs or
     * this method is called on a closed <code>PreparedStatement</code>
     * @since JDK 1.2 (JDK 1.1.x developers: read the overview for
     *   JDBCParameterMetaData)
     */
public synchronized void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
    checkSetParameterIndex(parameterIndex, false);
    int i = parameterIndex - 1;
    if (x == null) {
        parameterValues[i] = null;
        return;
    }
    Type outType = parameterTypes[i];
    long millis = x.getTime();
    int zoneOffset = 0;
    if (cal != null) {
        zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
    }
    switch(outType.typeCode) {
        case Types.SQL_TIMESTAMP:
            millis += zoneOffset;
            zoneOffset = 0;
        // $FALL-THROUGH$
        case Types.SQL_TIMESTAMP_WITH_TIME_ZONE:
            parameterValues[i] = new TimestampData(millis / 1000, x.getNanos(), zoneOffset / 1000);
            break;
        case Types.SQL_TIME:
            millis += zoneOffset;
            zoneOffset = 0;
        // $FALL-THROUGH$
        case Types.SQL_TIME_WITH_TIME_ZONE:
            parameterValues[i] = new TimeData((int) (millis / 1000), x.getNanos(), zoneOffset / 1000);
            break;
        default:
            throw Util.sqlException(ErrorCode.X_42561);
    }
}
Also used : Type(org.hsqldb_voltpatches.types.Type) TimestampData(org.hsqldb_voltpatches.types.TimestampData) TimeData(org.hsqldb_voltpatches.types.TimeData)

Example 10 with TimestampData

use of org.hsqldb_voltpatches.types.TimestampData in project voltdb by VoltDB.

the class JDBCResultSet method getDate.

/**
     * <!-- start generic documentation -->
     * Retrieves the value of the designated column in the current row
     * of this <code>ResultSet</code> object as a <code>java.sql.Date</code> object
     * in the Java programming language.
     * This method uses the given calendar to construct an appropriate millisecond
     * value for the date if the underlying database does not store
     * timezone information.
     * <!-- end generic documentation -->
     *
     * @param columnIndex the first column is 1, the second is 2, ...
     * @param cal the <code>java.util.Calendar</code> object
     * to use in constructing the date
     * @return the column value as a <code>java.sql.Date</code> object;
     * if the value is SQL <code>NULL</code>,
     * the value returned is <code>null</code> in the Java programming language
     * @exception SQLException if a database access error occurs
     * or this method is called on a closed result set
     * @since JDK 1.2 (JDK 1.1.x developers: read the overview for
     *  JDBCResultSet)
     */
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
    TimestampData t = (TimestampData) getColumnInType(columnIndex, Type.SQL_DATE);
    long millis = t.getSeconds() * 1000;
    int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
    return new Date(millis - zoneOffset);
}
Also used : TimestampData(org.hsqldb_voltpatches.types.TimestampData) Date(java.sql.Date)

Aggregations

TimestampData (org.hsqldb_voltpatches.types.TimestampData)11 Date (java.sql.Date)2 Timestamp (java.sql.Timestamp)2 TimeData (org.hsqldb_voltpatches.types.TimeData)2 Type (org.hsqldb_voltpatches.types.Type)2 BigDecimal (java.math.BigDecimal)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Constraint (org.hsqldb_voltpatches.Constraint)1 HSQLParseException (org.hsqldb_voltpatches.HSQLInterface.HSQLParseException)1 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)1 SchemaObject (org.hsqldb_voltpatches.SchemaObject)1 Session (org.hsqldb_voltpatches.Session)1 Table (org.hsqldb_voltpatches.Table)1 TextTable (org.hsqldb_voltpatches.TextTable)1 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)1 BinaryData (org.hsqldb_voltpatches.types.BinaryData)1 ClobData (org.hsqldb_voltpatches.types.ClobData)1 DateTimeType (org.hsqldb_voltpatches.types.DateTimeType)1 IntervalSecondData (org.hsqldb_voltpatches.types.IntervalSecondData)1