db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <Fisc...@seitenbau.net>
Subject [Fwd: RE: Date vs timestamp with Oracle]
Date Mon, 16 Aug 2004 11:22:45 GMT




Hi,

Just tried the patch and I had problems writing a timestamp to a Oracle 9i
Database.
I did the following:
- apply the patch to db.props from the torque-3.1-release (by the way: the
patch is reversed, i.e. I had to apply the -R option for patching)
- create an object with a timestamp value
(snippet from project-schema.xml)
  <table name="author" description="Author Table">
    <column
      name="author_id"
      required="true"
      primaryKey="true"
      type="INTEGER"
      description="Author Id"/>
    <column
      name="last_name"
      required="false"
      type="VARCHAR"
      size="128"
      description="Last Name"/>
    <column
      name="last_write_date"
      required="false"
      type="TIMESTAMP"
      description="Last write timestamp"/>
  </table>

- run the following code

  public void testLastWriteDate() {
    try {
      Author author = new Author();
      author.setLastWriteDate(someDateObject_see_below);
      author.save();
    }
    catch (Exception e) {
      fail(e.getClass().getName() + " : " + e.getMessage());
    }
  }

- The following errors occur:
If I use

author.setLastWriteDate(new Timestamp(System.currentTimeMillis()));
or
author.setLastWriteDate(new java.sql.Date(System.currentTimeMillis()));

I get the following exception:
ORA-01843: Kein g├╝ltiger Monat (in english: "no valid month")

If I use

author.setLastWriteDate(new java.util.Date());

I get:
ORA-01858: ein nicht-numerisches Zeichen wurde gefunden, wo numerisches
erwartet wurde (in english: a non-numeric character was found where a
numeric character was expected)

If I use the original db.props from the 3.1 release, the above test case
does not give an error, although the precision of the date is limited to
full seconds.

So it seems that, in addition to patching db.props, additional changes are
necessary to get a timestamp with better precision than seconds. However,
as db.props no longer appears in the CVS HEAD branch, I am not sure whether
it is worth while to pursue this issue for the 3.1.1 release.

By the way, the errors occur with Sarav's village jar (version 20040806) as
well as with the original village.jar.

Thomas


Scott Eade <seade@backstagetech.com.au> schrieb am 16.08.2004 06:27:31:

> I'm half way through applying the patch below to Torque 3.1.1 and HEAD.
> I don't use Oracle so I cannot if this is going to help or make things
> worse.
>
> Can all you Oracle users out there please let me know your opinion?
>
> I'm aiming to get a 3.1.1 release of torque out fairly soon and I would
> appreciate your feedback.
>
> BTW: I am including a reference to your Sarav's patched Village 2.0 code
> in the Oracle HOWTO - I hope this is okay.  Shrav: Have you made any
> attempts at getting your changes committed to back to Village?
>
> Scott
>
> --
> Scott Eade
> Backstage Technologies Pty. Ltd.
> http://www.backstagetech.com.au
>
>
> -------- Original Message --------
> Subject:    RE: Date vs timestamp with Oracle
> Date:    Thu, 17 Jun 2004 09:44:32 -0700
> From:    Daniel Huang <danihuan@cisco.com>
> Reply-To:    Apache Torque Users List <torque-user@db.apache.org>
> To:    Apache Torque Users List <torque-user@db.apache.org>
>
>
>
> Apply this patch to templates/sql/base/oracle/db.props:
>
> Index: db.props
> ===================================================================
> --- db.props    (revision 949)
> +++ db.props    (revision 948)
> @@ -19,8 +19,8 @@
>  VARCHAR = VARCHAR2
>  LONGVARCHAR = VARCHAR2 (2000)
>  DATE = DATE
> -TIME = TIME
> -TIMESTAMP = TIMESTAMP
> +TIME = DATE
> +TIMESTAMP = DATE
>  BINARY = LONG RAW
>  VARBINARY = BLOB
>  LONGVARBINARY = LONG RAW
>
> Regards,
> Daniel
>
> -----Original Message-----
> From: Raphael Mankin,,, [mailto:raph@panache.demon.co.uk]On Behalf Of
> raph@mankin.org.uk
> Sent: Monday, June 14, 2004 10:19 AM
> To: torque-user@db.apache.org
> Subject: Date vs timestamp with Oracle
>
> I have just changed some of my DB fields from DATE to TIMESTAMP, however
the
> generated Oracle DDL is still DATE which drops the time part.
>
> How do I get Torque to generate real date+time and not have to edit the
DDL
> by
> hand?
>
>
> BTW when I did this in mySQL I had no problems. I am using Torque 3.1.
>
> --
>                                Unfortunately, most programmers like to
>                                program. Some of them would rather
>                                program than eat or bathe.
>                                - Larry Constantine
>
>
> Raphael Mankin
> E-Mail: raph@panache.demon.co.uk
> ----------------------------------
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message