You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Rolf Moser <rm...@datacomm.ch> on 2004/08/18 19:51:53 UTC

[DBUtils] Oracle 9.2.0 JDBC Timestamp Problem

Hello

I just run into a Timestamp problem with the Oracle 9i (9.2.0) JDBC Driver
When calling rs.getObject(index) on a DB field, defined as Timestamp(6), 
the resulting object is a oracle.sql.TIMESTAMP and not a 
java.sql.Timestamp as with other JDBC Drivers. This leads to a null 
value propagation if your Bean Property is defined as java.sql.Timestamp.

If calling rs.getTimestamp(index), Oracle correctly converts the 
resulting value to a java.sql.Timestamp object.

I looked at the current source and added the following statement to the 
BeanProcessor processColumn Method as a workaround:

} else if(propType.equals(Timestamp.class)) {
        return rs.getTimestamp(index);

This ensures that for a Bean property of type java.sql.Timestamp the 
getTimestamp() method is called.
Otherwise the default getObject() mehod is called, so there souldn't be 
a problem if someone wants the Oracle enhanced oracle.sql.TIMESTAMP object.

Regards
Rolf


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [DBUtils] Oracle 9.2.0 JDBC Timestamp Problem

Posted by David Graham <gr...@yahoo.com>.
This change makes sense in DbUtils because we're already explicitly
calling ResultSet.get* methods for other types.  It doesn't hurt to add
getTimestamp() to that list.  

All concrete implementations of JDBC interfaces were removed from DbUtils
because of incompatibilities between JDK versions.  We replaced them with
the ProxyFactory class which allows you to build dynamic wrappers.

David

--- Henri Yandell <ba...@generationjava.com> wrote:

> 
> setObject is also quite screwed, and setTimestamp used to do some weird
> stuff in Oracle 9, unsure about their new driver.
> 
> My planned solution to this was to create a specific wrapper driver for
> Oracle that fixes Oracle's bugs, rather than put the fixes into things
> like dbutils.
> 
> Need to find that code again. DbUtils used to have an 'extended' driver
> concept that you could extend and put fixes like this in, but JDBC 2 vs
> 3
> made it get taken out of DbUtils I think.
> 
> Not a negative to the patch by the way, just an info dump having seen
> this
> problem before.
> 
> Hen
> 
> On Wed, 18 Aug 2004, David Graham wrote:
> 
> > Thanks for finding this!  It would be best to open a bugzilla ticket
> so
> > the issue isn't lost or forgotten.
> >
> > Thanks,
> > David
> >
> > --- Rolf Moser <rm...@datacomm.ch> wrote:
> >
> > > Hello
> > >
> > > I just run into a Timestamp problem with the Oracle 9i (9.2.0) JDBC
> > > Driver
> > > When calling rs.getObject(index) on a DB field, defined as
> Timestamp(6),
> > >
> > > the resulting object is a oracle.sql.TIMESTAMP and not a
> > > java.sql.Timestamp as with other JDBC Drivers. This leads to a null
> > > value propagation if your Bean Property is defined as
> > > java.sql.Timestamp.
> > >
> > > If calling rs.getTimestamp(index), Oracle correctly converts the
> > > resulting value to a java.sql.Timestamp object.
> > >
> > > I looked at the current source and added the following statement to
> the
> > > BeanProcessor processColumn Method as a workaround:
> > >
> > > } else if(propType.equals(Timestamp.class)) {
> > >         return rs.getTimestamp(index);
> > >
> > > This ensures that for a Bean property of type java.sql.Timestamp the
> > > getTimestamp() method is called.
> > > Otherwise the default getObject() mehod is called, so there souldn't
> be
> > > a problem if someone wants the Oracle enhanced oracle.sql.TIMESTAMP
> > > object.
> > >
> > > Regards
> > > Rolf
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [DBUtils] Oracle 9.2.0 JDBC Timestamp Problem

Posted by Henri Yandell <ba...@generationjava.com>.
setObject is also quite screwed, and setTimestamp used to do some weird
stuff in Oracle 9, unsure about their new driver.

My planned solution to this was to create a specific wrapper driver for
Oracle that fixes Oracle's bugs, rather than put the fixes into things
like dbutils.

Need to find that code again. DbUtils used to have an 'extended' driver
concept that you could extend and put fixes like this in, but JDBC 2 vs 3
made it get taken out of DbUtils I think.

Not a negative to the patch by the way, just an info dump having seen this
problem before.

Hen

On Wed, 18 Aug 2004, David Graham wrote:

> Thanks for finding this!  It would be best to open a bugzilla ticket so
> the issue isn't lost or forgotten.
>
> Thanks,
> David
>
> --- Rolf Moser <rm...@datacomm.ch> wrote:
>
> > Hello
> >
> > I just run into a Timestamp problem with the Oracle 9i (9.2.0) JDBC
> > Driver
> > When calling rs.getObject(index) on a DB field, defined as Timestamp(6),
> >
> > the resulting object is a oracle.sql.TIMESTAMP and not a
> > java.sql.Timestamp as with other JDBC Drivers. This leads to a null
> > value propagation if your Bean Property is defined as
> > java.sql.Timestamp.
> >
> > If calling rs.getTimestamp(index), Oracle correctly converts the
> > resulting value to a java.sql.Timestamp object.
> >
> > I looked at the current source and added the following statement to the
> > BeanProcessor processColumn Method as a workaround:
> >
> > } else if(propType.equals(Timestamp.class)) {
> >         return rs.getTimestamp(index);
> >
> > This ensures that for a Bean property of type java.sql.Timestamp the
> > getTimestamp() method is called.
> > Otherwise the default getObject() mehod is called, so there souldn't be
> > a problem if someone wants the Oracle enhanced oracle.sql.TIMESTAMP
> > object.
> >
> > Regards
> > Rolf
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [DBUtils] Oracle 9.2.0 JDBC Timestamp Problem

Posted by David Graham <gr...@yahoo.com>.
Thanks for finding this!  It would be best to open a bugzilla ticket so
the issue isn't lost or forgotten.

Thanks,
David

--- Rolf Moser <rm...@datacomm.ch> wrote:

> Hello
> 
> I just run into a Timestamp problem with the Oracle 9i (9.2.0) JDBC
> Driver
> When calling rs.getObject(index) on a DB field, defined as Timestamp(6),
> 
> the resulting object is a oracle.sql.TIMESTAMP and not a 
> java.sql.Timestamp as with other JDBC Drivers. This leads to a null 
> value propagation if your Bean Property is defined as
> java.sql.Timestamp.
> 
> If calling rs.getTimestamp(index), Oracle correctly converts the 
> resulting value to a java.sql.Timestamp object.
> 
> I looked at the current source and added the following statement to the 
> BeanProcessor processColumn Method as a workaround:
> 
> } else if(propType.equals(Timestamp.class)) {
>         return rs.getTimestamp(index);
> 
> This ensures that for a Bean property of type java.sql.Timestamp the 
> getTimestamp() method is called.
> Otherwise the default getObject() mehod is called, so there souldn't be 
> a problem if someone wants the Oracle enhanced oracle.sql.TIMESTAMP
> object.
> 
> Regards
> Rolf
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org