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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]]
>> Sent: Friday, March 08, 2002 11:00 AM
>> To: [EMAIL PROTECTED]
>> 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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to