From: | Andy W(dot) <toeffel(at)treufuss(dot)de> |
---|---|
To: | Dan McDaniel <Dan-McDaniel(at)smh(dot)com>, "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Inserting 'Dates' in database |
Date: | 2002-04-15 13:46:48 |
Message-ID: | 20020415134508.461AF476F93@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On Monday 08 April 2002 23:58, Dan McDaniel wrote:
> I am writing a simple Java user interface to a simple data base in
> Postgresql.
> I have no trouble connecting through my code using the JDBC driver. I can
> get several different Resultsets back with no problem. I am having trouble
> inserting data into the database. In particular Date data types. I get a
> message that says "Bad Date external representation".
> Here is how I am trying to solve the problem:
> I am getting a text string from the user interface and storing it in a
> String varialble called " dateInsert".
> Using a method I wrote call "convertDate()" , I am converting this date
> first to a java.util.Date object, a time object and finally to a
> java.sql.Date object called "sqldate" which I include in the Insert
> statement.
>
> here is the code snippet for the "convertDate() method:
>
> I pent allmost 18 hours trying to work this out yesterday and have run out
> of ideas. Can anyone suggest a direction for me?
Hi,
your convertDate() method looks OK - i guess your problem is with the SQL
Statement. Did you use a PreparedStatement and its setDate() method to build
your statement? If not, try this, it avoids a lot of trouble with Dates....
Greetings
Andreas
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas O'Dowd | 2002-04-15 14:34:00 | Re: Timestamp Problem (index out of range) |
Previous Message | Tarabas | 2002-04-15 12:54:12 | JDBC getTimestamp() Problem (index out of range) |