Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Storing time values via jdbc thin driver

 
Goto page Previous  1, 2
   Database Help (Home) -> Oracle -> Server RSS
Next:  record locks  
Author Message
sybrandb

External


Since: Dec 15, 2007
Posts: 172



(Msg. 16) Posted: Sat Nov 29, 2008 6:26 pm
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: comp>databases>oracle>server (more info?)

On Sat, 29 Nov 2008 18:11:55 +0100, "Chris Seidel" <cseidel DeleteThis @arcor.de>
wrote:

>sybrandb@hccnet.nl wrote:
>
>> http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/apxref.htm#i1005144
>
>Strings? I'm using typed values.
>If this syntax is the way to go, the driver should implement this, not the
>application.
>

It seems you know everything better, and don't want to follow up any
advice.
Why do you post here at all, if you already know the solution?

--
Sybrand Bakker
Senior Oracle DBA

 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Vladimir M. Zakharychev

External


Since: Jan 08, 2008
Posts: 90



(Msg. 17) Posted: Sun Nov 30, 2008 11:12 am
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Nov 29, 11:30 pm, hpuxrac <johnbhur....DeleteThis@sbcglobal.net> wrote:
> On Nov 28, 11:02 am, "Chris Seidel" <csei....DeleteThis@arcor.de> wrote:
>
> > Hi,
>
> > I have an Oracle 9.2 database.
> > If I use the 9.2 driver java.sql.Time is stored with 1900-01-01 HH:MM.
> > If I use the 10.2 driver java.sql.Time is stored with 1970-01-01 HH:MM.
>
> > Is this a know bug/feature?
> > Do I have to update all my records to 1970 when using oracle 10 driver?
>
> > Thank you
>
> I don't understand exactly what you are trying to do.
>
> Are you trying to store a time value from an application into a column
> in oracle which is in reality a date datatype in oracle?
>
> If that's the case ... oracle stores both a date and a time in a date
> datatype.
>
> If so ... you need to be careful about a database design where you are
> only using "part" of an oracle datatype.
>
> It is possible to create a char definition of length 8 for a column
> and from the application store in a field that looks like HH:MM:SS
> ( Hour Hour Minute Minute Second Second ).
>
> Of course it is also possible to use only the part of the date
> datatype that has time information and ignore/mask out the date
> portion if you know how to do it.
>
> There is also a datatype known as systimestamp that gives you better
> precision below the second level for a time value ... yes it also has
> a date part that also you can "ditch and/or ignore".
>
> Best place to start might be looking at the Oracle Concepts
> documentation and make sure that you understand the datatypes your
> application is trying to process against.

The trouble the OP has is that Oracle JDBC driver implementations of
the same Java type persistence are different between driver versions.
That this type is initially inappropriate because it is not natively
supported by the database is irrelevant to the case IMO. A lot of
people commented in this thread and all of them seem to agree that
choice of the data type was inappropriate because Oracle does not
support it, but that was not the question asked.

The issue here is that JDBC is supposed to be platform-independent, it
should work the same with any database, at least with *standard* types
(and TIME is a standard *core* SQL data type. By the way, Oracle
documentation claims *full* conformance to the Core SQL:2003 feature
F051 "Basic date and time", which mandates support of the TIME data
type.) Let's face it: Java programmers are not supposed to know
specifics of particular database platform they stuff their data into,
standard APIs should work the same against any database. For them, the
database is just some data storage, they don't really care how it
works and if it's any different from some other database. The database
vendor is expected to provide the driver that takes care of specific
implementation details, and Oracle claims to have provided such
driver. However, different versions of this driver give different
results for the same basic calls using only standard types. Then you
guys jump in and say that TIME is not supported in Oracle - so what?
The JDBC driver should take care of this, and it should do so in
consistent manner not changing between versions (I should stress we
are talking about core standard stuff here.) However, it does not -
its behavior changed since 10g.

Answering OP's question: this is a known behavior change between 8i/9i
and 10g JDBC drivers, documented in the Metalink note 269517.1 and bug
#3038799. If you are sure you will stick to 10g driver, just update
all rows so that the date component is Jan 1, 1970, I think this
should do the trick. If you are going to use different driver
versions, either stop using literals and start using binds with
properly initialized date component (the note recommends to always
initialize a Calendar object to Jan 1st, 1970 and then instantiate
java.sql.Time from it) or choose a different data type (INTERVAL DAY
TO SECOND, for example.)

Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com

 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
phil_herring

External


Since: Jan 16, 2008
Posts: 12



(Msg. 18) Posted: Sun Nov 30, 2008 4:23 pm
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Nov 29, 9:54 am, "gym dot scuba dot kennedy at gmail"
<kenned....RemoveThis@verizon.net> wrote:

> Actually no. Oracle only knows time and date together. In Oracle there is
> no stand alone time data type.

Strictly speaking, that isn't true; the INTERVAL type can be used to
specify a time of day without reference to any particular date. (The
reason being a time of day is just a period of time - i.e., an
interval - since the previous midnight.)

However, not many people would think to use an INTERVAL in this way.

-- Phil
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Chris Seidel

External


Since: Nov 28, 2008
Posts: 8



(Msg. 19) Posted: Sun Nov 30, 2008 5:25 pm
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

sybrandb.TakeThisOut@hccnet.nl wrote:

> It seems you know everything better, and don't want to follow up any
> advice.

What I have learnt from you: Don't ask a DBA about JDBC.

> Why do you post here at all, if you already know the solution?

Because here are people like Vladimir M. Zakharychev who know the correct
answer.

Thank you.
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Chris Seidel

External


Since: Nov 28, 2008
Posts: 8



(Msg. 20) Posted: Sun Nov 30, 2008 5:25 pm
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Vladimir M. Zakharychev wrote:

> Answering OP's question: this is a known behavior change between 8i/9i
> and 10g JDBC drivers, documented in the Metalink note 269517.1 and bug
> #3038799. If you are sure you will stick to 10g driver, just update
> all rows so that the date component is Jan 1, 1970, I think this
> should do the trick. If you are going to use different driver
> versions, either stop using literals and start using binds with
> properly initialized date component (the note recommends to always
> initialize a Calendar object to Jan 1st, 1970 and then instantiate
> java.sql.Time from it) or choose a different data type (INTERVAL DAY
> TO SECOND, for example.)


Thank you very much for the detailed explanation!
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
gym dot scuba dot kennedy

External


Since: Jun 08, 2008
Posts: 76



(Msg. 21) Posted: Sun Nov 30, 2008 10:26 pm
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Vladimir M. Zakharychev" <vladimir.zakharychev.DeleteThis@gmail.com> wrote in message
news:8a27958b-1467-4a68-8c18-e22703377553@h20g2000yqn.googlegroups.com...
On Nov 29, 11:30 pm, hpuxrac <johnbhur....DeleteThis@sbcglobal.net> wrote:
> On Nov 28, 11:02 am, "Chris Seidel" <csei....DeleteThis@arcor.de> wrote:
>
> > Hi,
>
> > I have an Oracle 9.2 database.
> > If I use the 9.2 driver java.sql.Time is stored with 1900-01-01 HH:MM.
> > If I use the 10.2 driver java.sql.Time is stored with 1970-01-01 HH:MM.
>
> > Is this a know bug/feature?
> > Do I have to update all my records to 1970 when using oracle 10 driver?
>
> > Thank you
>
> I don't understand exactly what you are trying to do.
>
> Are you trying to store a time value from an application into a column
> in oracle which is in reality a date datatype in oracle?
>
> If that's the case ... oracle stores both a date and a time in a date
> datatype.
>
> If so ... you need to be careful about a database design where you are
> only using "part" of an oracle datatype.
>
> It is possible to create a char definition of length 8 for a column
> and from the application store in a field that looks like HH:MM:SS
> ( Hour Hour Minute Minute Second Second ).
>
> Of course it is also possible to use only the part of the date
> datatype that has time information and ignore/mask out the date
> portion if you know how to do it.
>
> There is also a datatype known as systimestamp that gives you better
> precision below the second level for a time value ... yes it also has
> a date part that also you can "ditch and/or ignore".
>
> Best place to start might be looking at the Oracle Concepts
> documentation and make sure that you understand the datatypes your
> application is trying to process against.

The trouble the OP has is that Oracle JDBC driver implementations of
the same Java type persistence are different between driver versions.
That this type is initially inappropriate because it is not natively
supported by the database is irrelevant to the case IMO. A lot of
people commented in this thread and all of them seem to agree that
choice of the data type was inappropriate because Oracle does not
support it, but that was not the question asked.

The issue here is that JDBC is supposed to be platform-independent, it
should work the same with any database, at least with *standard* types
(and TIME is a standard *core* SQL data type. By the way, Oracle
documentation claims *full* conformance to the Core SQL:2003 feature
F051 "Basic date and time", which mandates support of the TIME data
type.) Let's face it: Java programmers are not supposed to know
specifics of particular database platform they stuff their data into,
standard APIs should work the same against any database. For them, the
database is just some data storage, they don't really care how it
works and if it's any different from some other database. The database
vendor is expected to provide the driver that takes care of specific
implementation details, and Oracle claims to have provided such
driver. However, different versions of this driver give different
results for the same basic calls using only standard types. Then you
guys jump in and say that TIME is not supported in Oracle - so what?
The JDBC driver should take care of this, and it should do so in
consistent manner not changing between versions (I should stress we
are talking about core standard stuff here.) However, it does not -
its behavior changed since 10g.

Answering OP's question: this is a known behavior change between 8i/9i
and 10g JDBC drivers, documented in the Metalink note 269517.1 and bug
#3038799. If you are sure you will stick to 10g driver, just update
all rows so that the date component is Jan 1, 1970, I think this
should do the trick. If you are going to use different driver
versions, either stop using literals and start using binds with
properly initialized date component (the note recommends to always
initialize a Calendar object to Jan 1st, 1970 and then instantiate
java.sql.Time from it) or choose a different data type (INTERVAL DAY
TO SECOND, for example.)

Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com

Excellent explanation. I have to disagree on part of it. Different RDBMS's
work different ways and Java programers should be aware of the differences.
If not then they are coding for the least common denominator. I know how
they love to be db agnostic, but they aren't language agnostic. (nor should
they be)
Jim
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Vladimir M. Zakharychev

External


Since: Jan 08, 2008
Posts: 90



(Msg. 22) Posted: Mon Dec 01, 2008 12:33 am
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Dec 1, 6:07 am, "gym dot scuba dot kennedy at gmail"
<kenned....TakeThisOut@verizon.net> wrote:
> "Vladimir M. Zakharychev" <vladimir.zakharyc....TakeThisOut@gmail.com> wrote in messagenews:8a27958b-1467-4a68-8c18-e22703377553@h20g2000yqn.googlegroups.com...
>
> Excellent explanation.  I have to disagree on part of it.  Different RDBMS's
> work different ways and Java programers should be aware of the differences.
> If not then they are coding for the least common denominator.  I know how
> they love to be db agnostic, but they aren't language agnostic. (nor should
> they be)
> Jim

You and me know that and advocate for database platform awareness,
among many others. Are we successful thus far? Doesn't look like.
People from the other side of the fence keep creating and advertising
frameworks that completely hide details from programmers and force
them to code for the least common denominator. Is it bad? We think it
is, they think it isn't. We say that by not being aware of what
particular database platform can do and ignoring built-in
functionality they essentially throw their investment into that
platform to the trash bin. They say who cares as long as it works and
development is so rapid and simple and resulting code is fully
platform-independent? (and performs equally bad everywhere, we might
add, but this fact usually becomes obvious too late in the development
cycle and then DBAs are being called in to "fix" the database because
apparently the bottleneck is there - how can it be anywhere else? Smile
In the world where time-to-market figures prevail in measuring project
success we will always be the minority. However, this doesn't mean we
should give up. Smile

Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Steve Howard

External


Since: Jan 16, 2008
Posts: 66



(Msg. 23) Posted: Mon Dec 01, 2008 6:46 am
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Dec 1, 3:33 am, "Vladimir M. Zakharychev"
<vladimir.zakharyc... DeleteThis @gmail.com>

> You and me know that and advocate for database platform awareness,
> among many others. Are we successful thus far? Doesn't look like.
> People from the other side of the fence keep creating and advertising
> frameworks that completely hide details from programmers and force
> them to code for the least common denominator. Is it bad? We think it
> is, they think it isn't. We say that by not being aware of what

I just heard in the last seven days from a J2EE developer (a really
good one, actually) "I don't want to know SQL".

I asked another J2EE guy a couple of years ago "what happens if you
switch application programming platforms from java?" He stared at me
for a couple of seconds and asked "Why would you want to do that?"
LOL! I still crack up every time I think of that.

Regards,

Steve (Sun Certified Java Programmer & Sun Certified Business
Component Developer Smile)
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Chris Seidel

External


Since: Nov 28, 2008
Posts: 8



(Msg. 24) Posted: Mon Dec 01, 2008 11:25 am
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Steve Howard wrote:

> I just heard in the last seven days from a J2EE developer (a really
> good one, actually) "I don't want to know SQL".

Because he knows EQL Wink

> I asked another J2EE guy a couple of years ago "what happens if you
> switch application programming platforms from java?"

Reverse engineering a cryptic db schema created by an OR-mapper Smile
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Palooka

External


Since: Jun 02, 2008
Posts: 97



(Msg. 25) Posted: Mon Dec 01, 2008 6:25 pm
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Steve Howard wrote:
> On Dec 1, 3:33 am, "Vladimir M. Zakharychev"
> <vladimir.zakharyc... DeleteThis @gmail.com>
>
>> You and me know that and advocate for database platform awareness,
>> among many others. Are we successful thus far? Doesn't look like.
>> People from the other side of the fence keep creating and advertising
>> frameworks that completely hide details from programmers and force
>> them to code for the least common denominator. Is it bad? We think it
>> is, they think it isn't. We say that by not being aware of what
>
> I just heard in the last seven days from a J2EE developer (a really
> good one, actually) "I don't want to know SQL".
>
> I asked another J2EE guy a couple of years ago "what happens if you
> switch application programming platforms from java?" He stared at me
> for a couple of seconds and asked "Why would you want to do that?"
> LOL! I still crack up every time I think of that.
>
When I was advocating (about 12 years ago) a switch from Wang VS PACE to
Oracle, I mentioned to my boss - the IT Director - that, given that we
planned to use Oracle features, and NOT write agnostic code, it might
prove expensive if we subsequently wanted to move from Oracle to a
different database.

He stared at me for a couple of seconds and asked "Why would we want to
do that?"

Palooka
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Thomas Kellerer

External


Since: Mar 12, 2008
Posts: 14



(Msg. 26) Posted: Tue Dec 02, 2008 3:25 am
Post subject: Re: Storing time values via jdbc thin driver [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Steve Howard, 01.12.2008 15:46:
> I just heard in the last seven days from a J2EE developer (a really
> good one, actually) "I don't want to know SQL".

That's the attitude that I'm trying to fight wherever I can.

Thomas
 >> Stay informed about: Storing time values via jdbc thin driver 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
jdbc thin driver password encryption - Hi, I am connecting from websphere to oracle 10G using jdbc thin client. Oracle does not have advanced encryption installed. Is it possible to have the user pwd used by the driver encrypted when we don't have the advanced encryption package installed ?...

Storing codes vs. human-intelligible values - best practice? - In a pre-existing project, many tables reference domain (lookup) tables of the general structure: # COL_NM (column name) -- a primary key containing a human- intelligible value; max varchar length varies by table, but typically no longer than 30..

Oracle characterset confusion when storing encoded passwords - Hello there, I hope someone can help me with a problem that I believe relates to character encoding in oracle.... I have a simple Java password encoding routing that XORs a password then sends it off the be stored in a VARCHAR2 field. The Java class is...

oracle Bug with JDBC ?? - Hi all, I'm currently doing some research on Oracle 10g server in our university (Uni of Wollongong,Australia). Well, I have a Java file which connects to the database and create and select some tables but doesn't close connection with the codes. and the...

Jdbc PreparedStatement doesn't support parsing - When will Oracle ever s&#118;pport JDBC properly? If I try this: prepstat = conn.prepareStatement(sqltext); meta = prepstat.getMetaData(); I get an ORA-01003 (no statement parsed) error. This works well with other JDBC drivers, and is a very importan...
   Database Help (Home) -> Oracle -> Server All times are: Pacific Time (US & Canada) (change)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]