You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2011/10/30 19:04:55 UTC

svn commit: r1195199 - in /commons/proper/jcs/trunk/src: changes/changes.xml java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java test/org/apache/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java

Author: tv
Date: Sun Oct 30 18:04:54 2011
New Revision: 1195199

URL: http://svn.apache.org/viewvc?rev=1195199&view=rev
Log:
Change DB type of column CREATE_TIME to TIMESTAMP, Rename column CREATE_TIME_SECONDS to UPDATE_TIME_SECONDS. Fixes JCS-84

Modified:
    commons/proper/jcs/trunk/src/changes/changes.xml
    commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
    commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java

Modified: commons/proper/jcs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/changes/changes.xml?rev=1195199&r1=1195198&r2=1195199&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/changes/changes.xml (original)
+++ commons/proper/jcs/trunk/src/changes/changes.xml Sun Oct 30 18:04:54 2011
@@ -20,6 +20,10 @@
 	</properties>
 	<body>
 		<release version="2.0" date="unreleased" description="JDK 1.5 based major release">
+            <action dev="tv" type="fix" issue="JCS-84" due-to="Aleksandar Ivanisevic">
+                Increase precision of CREATE_TIME, fix name of UPDATE_TIME_SECONDS
+                column.
+            </action>
             <action dev="tv" type="update">
                 Update IndexDisk and BlockDisk to use NIO in an attempt to fix
                 a timing-dependent test failure.

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java?rev=1195199&r1=1195198&r2=1195199&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java Sun Oct 30 18:04:54 2011
@@ -22,7 +22,7 @@ package org.apache.jcs.auxiliary.disk.jd
 import java.io.IOException;
 import java.io.Serializable;
 import java.sql.Connection;
-import java.sql.Date;
+import java.sql.Timestamp;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -62,8 +62,8 @@ import org.apache.jcs.utils.serializatio
  *                       CACHE_KEY                  VARCHAR(250)          NOT NULL,
  *                       REGION                     VARCHAR(250)          NOT NULL,
  *                       ELEMENT                    BLOB,
- *                       CREATE_TIME                DATE,
- *                       CREATE_TIME_SECONDS        BIGINT,
+ *                       CREATE_TIME                TIMESTAMP,
+ *                       UPDATE_TIME_SECONDS        BIGINT,
  *                       MAX_LIFE_SECONDS           BIGINT,
  *                       SYSTEM_EXPIRE_TIME_SECONDS BIGINT,
  *                       IS_ETERNAL                 CHAR(1),
@@ -328,7 +328,7 @@ public class JDBCDiskCache
         {
             String sqlI = "insert into "
                 + getJdbcDiskCacheAttributes().getTableName()
-                + " (CACHE_KEY, REGION, ELEMENT, MAX_LIFE_SECONDS, IS_ETERNAL, CREATE_TIME, CREATE_TIME_SECONDS, SYSTEM_EXPIRE_TIME_SECONDS) "
+                + " (CACHE_KEY, REGION, ELEMENT, MAX_LIFE_SECONDS, IS_ETERNAL, CREATE_TIME, UPDATE_TIME_SECONDS, SYSTEM_EXPIRE_TIME_SECONDS) "
                 + " values (?, ?, ?, ?, ?, ?, ?, ?)";
 
             PreparedStatement psInsert = con.prepareStatement( sqlI );
@@ -344,8 +344,8 @@ public class JDBCDiskCache
             {
                 psInsert.setString( 5, "F" );
             }
-            Date createTime = new Date( ce.getElementAttributes().getCreateTime() );
-            psInsert.setDate( 6, createTime );
+            Timestamp createTime = new Timestamp( ce.getElementAttributes().getCreateTime() );
+            psInsert.setTimestamp( 6, createTime );
 
             long now = System.currentTimeMillis() / 1000;
             psInsert.setLong( 7, now );
@@ -392,13 +392,13 @@ public class JDBCDiskCache
         try
         {
             sqlU = "update " + getJdbcDiskCacheAttributes().getTableName()
-                + " set ELEMENT  = ?, CREATE_TIME = ?, CREATE_TIME_SECONDS = ?, " + " SYSTEM_EXPIRE_TIME_SECONDS = ? "
+                + " set ELEMENT  = ?, CREATE_TIME = ?, UPDATE_TIME_SECONDS = ?, " + " SYSTEM_EXPIRE_TIME_SECONDS = ? "
                 + " where CACHE_KEY = ? and REGION = ?";
             PreparedStatement psUpdate = con.prepareStatement( sqlU );
             psUpdate.setBytes( 1, element );
 
-            Date createTime = new Date( ce.getElementAttributes().getCreateTime() );
-            psUpdate.setDate( 2, createTime );
+            Timestamp createTime = new Timestamp( ce.getElementAttributes().getCreateTime() );
+            psUpdate.setTimestamp( 2, createTime );
 
             long now = System.currentTimeMillis() / 1000;
             psUpdate.setLong( 3, now );
@@ -876,7 +876,7 @@ public class JDBCDiskCache
             // String sql = "delete from " +
             // getJdbcDiskCacheAttributes().getTableName() + " where REGION = '"
             // + this.getCacheName() + "' and IS_ETERNAL = 'F' and (" + now
-            // + " - CREATE_TIME_SECONDS) > MAX_LIFE_SECONDS";
+            // + " - UPDATE_TIME_SECONDS) > MAX_LIFE_SECONDS";
 
             String sql = "delete from " + getJdbcDiskCacheAttributes().getTableName()
                 + " where IS_ETERNAL = ? and REGION = ? and ? > SYSTEM_EXPIRE_TIME_SECONDS";

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java?rev=1195199&r1=1195198&r2=1195199&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/HsqlSetupTableUtil.java Sun Oct 30 18:04:54 2011
@@ -11,7 +11,7 @@ public class HsqlSetupTableUtil
      * SETUP a TABLE FOR CACHE testing
      * <p>
      * @param cConn
-     * @param tableName 
+     * @param tableName
      */
     public static void setupTABLE( Connection cConn, String tableName )
     {
@@ -23,8 +23,8 @@ public class HsqlSetupTableUtil
         createSql.append( "CACHE_KEY             VARCHAR(250)          NOT NULL, " );
         createSql.append( "REGION                VARCHAR(250)          NOT NULL, " );
         createSql.append( "ELEMENT               BINARY, " );
-        createSql.append( "CREATE_TIME           DATE, " );
-        createSql.append( "CREATE_TIME_SECONDS   BIGINT, " );
+        createSql.append( "CREATE_TIME           TIMESTAMP, " );
+        createSql.append( "UPDATE_TIME_SECONDS   BIGINT, " );
         createSql.append( "MAX_LIFE_SECONDS      BIGINT, " );
         createSql.append( "SYSTEM_EXPIRE_TIME_SECONDS      BIGINT, " );
         createSql.append( "IS_ETERNAL            CHAR(1), " );