cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r439478 - /incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/jpa/itest/ItestDBUtils.java
Date Fri, 01 Sep 2006 20:57:02 GMT
Author: aadamchik
Date: Fri Sep  1 13:57:02 2006
New Revision: 439478

URL: http://svn.apache.org/viewvc?rev=439478&view=rev
Log:
chugging along with itests

Modified:
    incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/jpa/itest/ItestDBUtils.java

Modified: incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/jpa/itest/ItestDBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/jpa/itest/ItestDBUtils.java?rev=439478&r1=439477&r2=439478&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/jpa/itest/ItestDBUtils.java
(original)
+++ incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/jpa/itest/ItestDBUtils.java
Fri Sep  1 13:57:02 2006
@@ -22,6 +22,8 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
 
 public class ItestDBUtils {
 
@@ -43,7 +45,7 @@
         }
     }
 
-    public static Object getSingleValue(String table, String column) throws SQLException
{
+    public static Object getObject(String table, String column) throws SQLException {
         final String sql = "select " + column + " from " + table;
 
         final Object[] result = new Object[1];
@@ -58,8 +60,8 @@
         template.execute(sql);
         return result[0];
     }
-    
-    public static byte getSingleByte(String table, String column) throws SQLException {
+
+    public static byte getByte(String table, String column) throws SQLException {
         final String sql = "select " + column + " from " + table;
 
         final byte[] result = new byte[1];
@@ -75,8 +77,8 @@
         template.execute(sql);
         return result[0];
     }
-    
-    public static byte[] getSingleBytes(String table, String column) throws SQLException
{
+
+    public static byte[] getBytes(String table, String column) throws SQLException {
         final String sql = "select " + column + " from " + table;
 
         final byte[][] result = new byte[1][];
@@ -93,7 +95,7 @@
         return result[0];
     }
 
-    public static int getSingleInt(String table, String column) throws SQLException {
+    public static int getInt(String table, String column) throws SQLException {
         final String sql = "select " + column + " from " + table;
 
         final int[] result = new int[1];
@@ -109,8 +111,42 @@
         template.execute(sql);
         return result[0];
     }
-    
-    public static boolean getSingleBoolean(String table, String column) throws SQLException
{
+
+    public static long getLong(String table, String column) throws SQLException {
+        final String sql = "select " + column + " from " + table;
+
+        final long[] result = new long[1];
+
+        RowTemplate template = new RowTemplate() {
+
+            @Override
+            void readRow(ResultSet rs, String sql) throws SQLException {
+                result[0] = rs.getLong(1);
+            }
+        };
+
+        template.execute(sql);
+        return result[0];
+    }
+
+    public static double getDouble(String table, String column) throws SQLException {
+        final String sql = "select " + column + " from " + table;
+
+        final double[] result = new double[1];
+
+        RowTemplate template = new RowTemplate() {
+
+            @Override
+            void readRow(ResultSet rs, String sql) throws SQLException {
+                result[0] = rs.getDouble(1);
+            }
+        };
+
+        template.execute(sql);
+        return result[0];
+    }
+
+    public static boolean getBoolean(String table, String column) throws SQLException {
         final String sql = "select " + column + " from " + table;
 
         final boolean[] result = new boolean[1];
@@ -120,6 +156,64 @@
             @Override
             void readRow(ResultSet rs, String sql) throws SQLException {
                 result[0] = rs.getBoolean(1);
+            }
+        };
+
+        template.execute(sql);
+        return result[0];
+    }
+
+    public static java.util.Date getUtilDate(String table, String column)
+            throws SQLException {
+        Timestamp ts = getTimestamp(table, column);
+        return ts != null ? new java.util.Date(ts.getTime()) : null;
+    }
+
+    public static java.sql.Date getSqlDate(String table, String column)
+            throws SQLException {
+        final String sql = "select " + column + " from " + table;
+
+        final java.sql.Date[] result = new java.sql.Date[1];
+
+        RowTemplate template = new RowTemplate() {
+
+            @Override
+            void readRow(ResultSet rs, String sql) throws SQLException {
+                result[0] = rs.getDate(1);
+            }
+        };
+
+        template.execute(sql);
+        return result[0];
+    }
+
+    public static Time getTime(String table, String column) throws SQLException {
+        final String sql = "select " + column + " from " + table;
+
+        final Time[] result = new Time[1];
+
+        RowTemplate template = new RowTemplate() {
+
+            @Override
+            void readRow(ResultSet rs, String sql) throws SQLException {
+                result[0] = rs.getTime(1);
+            }
+        };
+
+        template.execute(sql);
+        return result[0];
+    }
+
+    public static Timestamp getTimestamp(String table, String column) throws SQLException
{
+        final String sql = "select " + column + " from " + table;
+
+        final Timestamp[] result = new Timestamp[1];
+
+        RowTemplate template = new RowTemplate() {
+
+            @Override
+            void readRow(ResultSet rs, String sql) throws SQLException {
+                result[0] = rs.getTimestamp(1);
             }
         };
 



Mime
View raw message