Author: sumedha
Date: Sat Dec 22 22:03:57 2007
New Revision: 11691

Log:

support for data type TIME

Modified:
   
trunk/commons/data-services/src/main/java/org/wso2/ws/dataservice/DBUtils.java

Modified: 
trunk/commons/data-services/src/main/java/org/wso2/ws/dataservice/DBUtils.java
==============================================================================
--- 
trunk/commons/data-services/src/main/java/org/wso2/ws/dataservice/DBUtils.java  
    (original)
+++ 
trunk/commons/data-services/src/main/java/org/wso2/ws/dataservice/DBUtils.java  
    Sat Dec 22 22:03:57 2007
@@ -33,6 +33,7 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Time;
 import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -960,7 +961,11 @@
                        }else 
if(DBConstants.DataTypes.TIMESTAMP.equals(sqlType)){
                                Timestamp timestamp = 
getTimestamp(value,paramName);
                                sqlQuery.setTimestamp(i+1,timestamp);
+                       }else if(DBConstants.DataTypes.TIME.equals(sqlType)){
+                               Time time = getTime(value,paramName);
+                               sqlQuery.setTime(i+1,time);
                        }
+
                        
                }
                return sqlQuery;
@@ -978,6 +983,7 @@
         * @param value - String value to be converted to timestamp.
         * Should be either in format "yyyy-MM-dd hh:mm:ss" or "yyyy-MM-dd 
hh:mm:ss.SSSSSS"
         * @param paramName - name given to parameter in data service 
configuration file
+        * @return Timestamp object containing passed value
         */
        private static Timestamp getTimestamp(String value,String paramName)
        throws AxisFault{
@@ -1000,5 +1006,28 @@
            }
            return timestamp;
        }
+       
+       /**
+        * @param value - String value to be converted to time.Should be either 
in format "hh:mm:ss"
+        * @param paramName - name given to parameter in data service 
configuration file
+        * @return Time object containing passed value
+        */
+       
+       private static Time getTime(String value, String paramName)
+                       throws AxisFault {
+               java.sql.Time time;
+               try {
+                       SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
+                       java.util.Date date = sdf.parse(value);
+                       time = new java.sql.Time(date.getTime());
+               } catch (ParseException e) {
+                       log.error("Incorrect Time format for parameter : "+ 
paramName
+                                                                       + 
".Time should be in the format hh:mm:ss",e);
+                       throw new AxisFault("Incorrect Time format for 
parameter : "+ paramName
+                                                                       + 
".Time should be in the format hh:mm:ss",e);
+               }
+               return time;
+       }
+       
                
 }

_______________________________________________
Commons-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commons-dev

Reply via email to