From: teser3 on
I have a JDBC current date and time insert into Oracle 9i that almost
works. It submits the current date and a fixed time into the Oracle
date type field. I am using Tomcat 6.0.20.
For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will
insert as: 16-Feb-2010 12:00:00 AM
The date part works but the time always shows 12:00:00 AM no matter
what date or time the data is inserted.

Here is what I have for my JDBC inserts and I also tried something
with DateFormat:
PreparedStatement ps;
Date mydate = new Date(new java.util.Date().getTime());
//insert statement here....

stmt.setDate(1,mydate);


I also tried:
PreparedStatement ps;
java.sql.Timestamp mydate = new java.sql.Timestamp(new
java.util.Date().getTime());
SimpleDateFormat fmt = new SimpleDateFormat(....
//insert statement here....
ps.setTimestamp(1,fmt.format(mydate));


Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
Anyway to get the current date and time? For example if I insert the
data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in
Oracle.
From: Arne Vajhøj on
On 16-02-2010 19:53, teser3(a)hotmail.com wrote:
> I have a JDBC current date and time insert into Oracle 9i that almost
> works. It submits the current date and a fixed time into the Oracle
> date type field. I am using Tomcat 6.0.20.
> For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will
> insert as: 16-Feb-2010 12:00:00 AM
> The date part works but the time always shows 12:00:00 AM no matter
> what date or time the data is inserted.
>
> Here is what I have for my JDBC inserts and I also tried something
> with DateFormat:
> PreparedStatement ps;
> Date mydate = new Date(new java.util.Date().getTime());
> //insert statement here....
>
> stmt.setDate(1,mydate);
>
>
> I also tried:
> PreparedStatement ps;
> java.sql.Timestamp mydate = new java.sql.Timestamp(new
> java.util.Date().getTime());
> SimpleDateFormat fmt = new SimpleDateFormat(....
> //insert statement here....
> ps.setTimestamp(1,fmt.format(mydate));
>
> Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
> Anyway to get the current date and time? For example if I insert the
> data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in
> Oracle.

What data types is the column in Oracle?

And how do you get .setTimestamp(String) to compile????

Arne

From: Arne Vajhøj on
On 16-02-2010 20:18, Lew wrote:
> teser3(a)hotmail.com wrote:
>>> I have a JDBC current date and time insert into Oracle 9i that almost
>>> works. It submits the current date and a fixed time into the Oracle
>>> date type field. I am using Tomcat 6.0.20.
>>> For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will
>>> insert as: 16-Feb-2010 12:00:00 AM
>>> The date part works but the time always shows 12:00:00 AM no matter
>>> what date or time the data is inserted.
>>>
>>> Here is what I have for my JDBC inserts and I also tried something
>>> with DateFormat:
>>> PreparedStatement ps;
>>> Date mydate = new Date(new java.util.Date().getTime());
>>> //insert statement here....
>>>
>>> stmt.setDate(1,mydate);
>>>
>>>
>>> I also tried:
>>> PreparedStatement ps;
>>> java.sql.Timestamp mydate = new java.sql.Timestamp(new
>>> java.util.Date().getTime());
>>> SimpleDateFormat fmt = new SimpleDateFormat(....
>>> //insert statement here....
>>> ps.setTimestamp(1,fmt.format(mydate));
>>>
>>> Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
>>> Anyway to get the current date and time? For example if I insert the
>>> data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in
>>> Oracle.
>
> Arne Vajhøj wrote:
>> What data types is the column in Oracle?
>>
>> And how do you get .setTimestamp(String) to compile????
>
> And why repeat your post that I just spent twenty minutes answering,
> only to see that Arne found the same questionable aspects?

Luckily I only spend 1 minute ...

:-)

Arne

From: Lew on
teser3(a)hotmail.com wrote:
>> I have a JDBC current date and time insert into Oracle 9i that almost
>> works. It submits the current date and a fixed time into the Oracle
>> date type field. I am using Tomcat 6.0.20.
>> For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will
>> insert as: 16-Feb-2010 12:00:00 AM
>> The date part works but the time always shows 12:00:00 AM no matter
>> what date or time the data is inserted.
>>
>> Here is what I have for my JDBC inserts and I also tried something
>> with DateFormat:
>> PreparedStatement ps;
>> Date mydate = new Date(new java.util.Date().getTime());
>> //insert statement here....
>>
>> stmt.setDate(1,mydate);
>>
>>
>> I also tried:
>> PreparedStatement ps;
>> java.sql.Timestamp mydate = new java.sql.Timestamp(new
>> java.util.Date().getTime());
>> SimpleDateFormat fmt = new SimpleDateFormat(....
>> //insert statement here....
>> ps.setTimestamp(1,fmt.format(mydate));
>>
>> Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
>> Anyway to get the current date and time? For example if I insert the
>> data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in
>> Oracle.

Arne Vajhøj wrote:
> What data types is the column in Oracle?
>
> And how do you get .setTimestamp(String) to compile????

And why repeat your post that I just spent twenty minutes answering, only to
see that Arne found the same questionable aspects?

Give us a question that makes sense, teser.

--
Lew