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" <[EMAIL PROTECTED]> To: "Jakarta Commons Users List" <[email protected]> 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
