Return-Path: Delivered-To: apmail-jakarta-turbine-dev-archive@apache.org Received: (qmail 59843 invoked from network); 12 Mar 2002 01:10:34 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Mar 2002 01:10:34 -0000 Received: (qmail 25846 invoked by uid 97); 12 Mar 2002 01:10:40 -0000 Delivered-To: qmlist-jakarta-archive-turbine-dev@jakarta.apache.org Received: (qmail 25828 invoked by uid 97); 12 Mar 2002 01:10:40 -0000 Mailing-List: contact turbine-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Turbine Developers List" Reply-To: "Turbine Developers List" Delivered-To: mailing list turbine-dev@jakarta.apache.org Received: (qmail 25817 invoked from network); 12 Mar 2002 01:10:39 -0000 Sender: dlr@despot.finemaltcoding.com To: "Turbine Developers List" Subject: Re: [PATCH] DBOracle, DBPostgres References: Content-Type: text/plain; charset=US-ASCII From: Daniel Rall Date: Mon, 11 Mar 2002 17:10:45 -0800 In-Reply-To: (Fedor Karpelevitch's message of "Fri, 8 Mar 2002 11:21:51 -0800") Message-ID: Lines: 148 User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.1 (Cuyahoga Valley) MIME-Version: 1.0 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I believe that by "standard JDBC escapes" Fedor refers to section A.1.3 of the following: http://java.sun.com/products/jdbc/driverdevs.html Here's the applicable section: "An escape syntax that supports the Selective Transitional Level semantics. A driver should scan for and translate this escape syntax into DBMS-specific syntax. Note that these escapes need only be supported where the underlying database supports the corresponding Transitional Level semantics. Where appropriate, an escape syntax must be included for stored procedures, time and date literals, scalar functions, LIKE escape characters, and outer joins." If drivers don't support JDBC escapes, they are not JDBC 3.0 complient. Personally, I don't think that Torque should require 3.0 complience -- 2.0 is much better supported. If we're seeing problems with JDBC escapes not being interpolated by JDBC drviers, the drivers in question are likely not JDBC 3.0 complient. - Dan Fedor Karpelevitch writes: > do you mean that standard JDBC escapes do not work for them? If they do work > then you simply need to remove the getDateString() methods from adapters so > that they use default impl. > > -- > fedor. > > ---- > Broad-mindedness, n.: > The result of flattening high-mindedness out. > > >> -----Original Message----- >> From: Bill Schneider [mailto:bschneider@vecna.com] >> Sent: Friday, March 08, 2002 11:00 AM >> To: turbine-dev@jakarta.apache.org >> Subject: [PATCH] DBOracle, DBPostgres >> >> >> This patches the Oracle and Postgres adapters for Torque, which were >> breaking when using dates in criteria, for example >> >> criteria.add(DATE_COLUMN, new java.util.Date(), Criteria.LESS_EQUAL); >> >> Index: src/java/org/apache/torque/adapter/DBOracle.java >> =================================================================== >> RCS file: >> /home/cvspublic/jakarta-turbine-torque/src/java/org/apache/tor >> que/adapter/DBOracle.java,v >> retrieving revision 1.8 >> diff -u -r1.8 DBOracle.java >> --- src/java/org/apache/torque/adapter/DBOracle.java 22 Aug >> 2001 20:12:08 -0000 1.8 >> +++ src/java/org/apache/torque/adapter/DBOracle.java 8 Mar >> 2002 18:25:13 -0000 >> @@ -55,6 +55,7 @@ >> */ >> >> import java.util.Date; >> +import java.text.SimpleDateFormat; >> import java.lang.reflect.Method; >> >> import java.sql.Connection; >> @@ -74,6 +75,9 @@ >> public class DBOracle >> extends DB >> { >> + private static final SimpleDateFormat DATE_FORMATTER = >> + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); >> + >> /** >> * Empty constructor. >> */ >> @@ -222,7 +226,7 @@ >> */ >> public String getDateString(String dateString) >> { >> - return "TO_DATE('" + dateString + "', 'yyyy-mm-dd >> hh24:mi:ss..' )"; >> + return "TO_DATE('" + dateString + "', 'yyyy-mm-dd hh24:mi:ss' )"; >> } >> >> /** >> @@ -233,6 +237,7 @@ >> */ >> public String getDateString(Date date) >> { >> - return "TO_DATE('" + date.toString() + "', 'yyyy-mm-dd >> hh24:mi:ss..' )"; >> + return "TO_DATE('" + DATE_FORMATTER.format(date) + >> + "', 'yyyy-mm-dd hh24:mi:ss' )"; >> } >> } >> Index: src/java/org/apache/torque/adapter/DBPostgres.java >> =================================================================== >> RCS file: >> /home/cvspublic/jakarta-turbine-torque/src/java/org/apache/tor >> que/adapter/DBPostgres.java,v >> retrieving revision 1.5 >> diff -u -r1.5 DBPostgres.java >> --- src/java/org/apache/torque/adapter/DBPostgres.java >> 21 Feb 2002 16:55:19 -0000 1.5 >> +++ src/java/org/apache/torque/adapter/DBPostgres.java >> 8 Mar 2002 18:25:13 -0000 >> @@ -56,6 +56,8 @@ >> >> import java.sql.Connection; >> import java.sql.SQLException; >> +import java.util.Date; >> +import java.text.SimpleDateFormat; >> >> /** >> * This is used to connect to PostgresQL databases. >> @@ -68,6 +70,9 @@ >> public class DBPostgres >> extends DB >> { >> + private static final SimpleDateFormat DATE_FORMATTER = >> + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); >> + >> /** >> * Empty constructor. >> */ >> @@ -202,5 +207,17 @@ >> public int getLimitStyle() >> { >> return DB.LIMIT_STYLE_POSTGRES; >> + } >> + >> + /** >> + * This method is used to format any date string. >> + * Database can use different default date formats. >> + * >> + * @return The proper date formatted String. >> + */ >> + public String getDateString(Date date) >> + { >> + return "TO_TIMESTAMP('" + DATE_FORMATTER.format(date) + >> + >> "', 'yyyy-mm-dd hh24:mi:ss' )"; >> } >> } -- To unsubscribe, e-mail: For additional commands, e-mail: