commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chetan" <chetan.ar...@ebusinessware.us>
Subject Re: Problem with Result Set returning null instead of Empty String
Date Wed, 25 Jan 2006 12:58:15 GMT
Thanks Paul..

I have a related question here...

Does the oracle driver (that comes with classes111.jar) have a connection
pooling manager that we could use instead of DBCP ? If it does then is it
better or worse than DBCP ?

Thanks,

Chetan

----- Original Message -----
From: "paul womack" <pwomack@papermule.co.uk>
To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
Sent: Wednesday, January 25, 2006 5:37 PM
Subject: Re: Problem with Result Set returning null instead of Empty String


> Stefan Rufer wrote:
> > On Wed, 25 Jan 2006, Chetan wrote:
> >
> >> Earlier in my code, whenever i was doing a resultSet.getString('some
> >> column
> >> name'), the return value would be an empty string ('') in case the
> >> column in
> >> the database was null. However, after using DBCP, similar statements
> >> return
> >
> >
> > The JDBC specification (e.g. JDBC 3.0, Chapter 14.2.3.3) states that for
> > database rows that contain NULL: "Column values that map to Java Object
> > types are returned as a Java null;"
> >
> > Your implementation does not follow the JDBC specification, therefore
> > it's not possible to change the implementation easily.
> >
> >> Is there any way by which i could make the DBCP connection broker
> >> return an
> >> empty string instead of a null so that i dont need to make changes in
> >> numerous places in my application to handle the null pointer case ?
> >
> >
> > I strongly recommend you to follow the JDBC specification (better change
> > your implementation now than later). This will make it possible to
> > exchange the implementation as you like.
>
> Be VERY careful here; some databases (blech) for character
> data treat "empty string" and null interchangeably
> (i.e. use one as a proxy for the other)
>
>  From some testing at our company:
>
> >     *  HSQLDB behaves as you would hope, it's a string with no
characters in.
> >     * Oracle treats a zero length string as if it were NULL, i.e. it
cannot be inserted into a row that does not allow nulls, testing for
equality will fail, even against a column where a zero length string was
inserted. Retrieving a zero length string from the database returns a null
string.
> >     * Sybase replaces a zero length string with a space character.
Testing external to the database against a zero length string will fail,
because a zero length string is not the same as a space character. Testing
internally will succeed, because both sides of the expression will be
converted into space characters. Internally testing against a space would
also succeed however which is wrong.
>
>
> What you're seeing may not be a JDBC/DBCP issue.
>
>    BugBear
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>



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


Mime
View raw message