commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson, James H [IT]" <james.h.ander...@citigroup.com>
Subject RE: [DBUtils] SqlNullCheckedResultSet not replacing nulls
Date Wed, 21 Apr 2004 18:22:38 GMT
Sorry, I didn't mean I wouldn't use ANY of DbUtils, just not the SqlNullCheckedResultSet class,
for the time being. From what I've seen of the rest of DbUtils, it's awesome!

-----Original Message-----
From: David Graham [mailto:grahamdavid1980@yahoo.com]
Sent: Wednesday, April 21, 2004 2:07 PM
To: Jakarta Commons Users List
Subject: RE: [DBUtils] SqlNullCheckedResultSet not replacing nulls



--- "Anderson, James H [IT]" <james.h.anderson@citigroup.com> wrote:
> I doublechecked to make sure that the tested fields were indeed null (by
> checking column==null), and they were. So that rules out the possibility
> that the driver is returning non-null objects. But what do you mean by
> "SQL NULL"? Is that different than plain ol' null?

I just mean that if you ran this query:
select mycol from mytbl where mycol is null;

you would get results back and they would be NULL.

> 
> I guess I'll have to postpone use of this package until sometime in the
> future; I don't have time to dive into Eclipse at the moment :-(

Not getting one feature of the package to work is hardly a reason to not
use the rest of the features.  I would never go back to coding raw JDBC
cleanup code after using this package.  It's just a waste of time.

David

> 
> Thanks for your help.
> 
> jim
> 
> -----Original Message-----
> From: David Graham [mailto:grahamdavid1980@yahoo.com]
> Sent: Wednesday, April 21, 2004 12:24 PM
> To: Jakarta Commons Users List
> Subject: RE: [DBUtils] SqlNullCheckedResultSet not replacing nulls
> 
> 
> 
> --- "Anderson, James H [IT]" <james.h.anderson@citigroup.com> wrote:
> > Could you recommend a good debugger? I'm not using an IDE.
> 
> I use Eclipse: www.eclipse.org.
> 
> > 
> > But, as you pointed out, the invoke() method in DbUtils is pretty
> > simple, so I'm not sure how this would help, and I'm relectant to try
> > debugging the Driver code...
> 
> The two things that I see could go wrong in that method are:
> 1.  rs.wasNull() not implemented correctly which would be a driver
> issue. 
> Or, maybe wasNull() is implemented correctly and your column value is
> something other than SQL NULL.  Are you sure the value you're retrieving
> is NULL?
> 
> 2.  The getNull* method corresponding to the ResultSet.get* method isn't
> found correctly.  The test cases pass and I think I tried this a while
> back on a postgres db just to be sure.
> 
> Stepping through it with a debugger will show you exactly why it's
> failing.
> 
> David
> 
> > 
> > -----Original Message-----
> > From: David Graham [mailto:grahamdavid1980@yahoo.com]
> > Sent: Wednesday, April 21, 2004 11:53 AM
> > To: Jakarta Commons Users List
> > Subject: RE: [DBUtils] SqlNullCheckedResultSet not replacing nulls
> > 
> > 
> > 
> > --- "Anderson, James H [IT]" <james.h.anderson@citigroup.com> wrote:
> > > Is there any good doc on Java reflexion anywhere? I suppose I could
> > pour
> > > over the javadoc, but from the looks of it that would take days, and
> I
> > > just don't have the time.
> > 
> > Reflection isn't that tough to figure out but it might be faster to
> step
> > through the DbUtils code in your debugger to find out exactly why the
> > getNull* methods aren't getting called.
> > 
> > David
> > 
> > > 
> > > Thanks,
> > > 
> > > jim
> > > 
> > > -----Original Message-----
> > > From: David Graham [mailto:grahamdavid1980@yahoo.com]
> > > Sent: Wednesday, April 21, 2004 9:18 AM
> > > To: Jakarta Commons Users List
> > > Subject: Re: [DBUtils] SqlNullCheckedResultSet not replacing nulls
> > > 
> > > 
> > > Your code looks correct.  What JDBC driver are you using?  The
> > > implementation of SqlNullCheckedResultSet is dependent on
> > > ResultSet.wasNull() being implemented properly.  Of course, it might
> > be
> > > a
> > > bug in DbUtils but the test cases pass for this class (unless the
> > tests
> > > have bugs too :-).
> > > 
> > > Here's the relevant method from DbUtils:
> > >
> >
>
http://jakarta.apache.org/commons/dbutils/xref/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.html#354
> > > 
> > > There's not a lot of logic there that could go wrong.
> > > 
> > > David
> > > 
> > > --- "Anderson, James H [IT]" <james.h.anderson@citigroup.com> wrote:
> > > > In the following code snippet, SqlNullCheckedResultSet is not
> > > replacing
> > > > nulls, neither for String nor Date results.
> > > > 
> > > > Anyone have an idea what's wrong?
> > > > 
> > > > Thanks,
> > > > 
> > > > jim
> > > > 
> > > >         [...]
> > > > 
> > > >         try {
> > > >             Class.forName("com.mysql.jdbc.Driver").newInstance();
> > > >             conn = DriverManager.getConnection(url, user, pswd);
> > > >  
> > > >             MapListHandler mlh = new MapListHandler() {
> > > >                     public Object handle (ResultSet rs) {
> > > >                         SqlNullCheckedResultSet wrapper = new
> > > > SqlNullCheckedResultSet(rs);
> > > >                         wrapper.setNullString("--n/a--");
> > > >                         wrapper.setNullDate(today);
> > > >                         rs =
> > > > ProxyFactory.instance().createResultSet(wrapper);
> > > >                         Object returnVal = null;
> > > >                         try {
> > > >                             System.out.println("*** HERE ***");
> > > >                             returnVal = super.handle(rs);
> > > >                         } catch (Exception e) {
> > > >                             System.out.println(e.getMessage());
> > > >                         }
> > > >                         return returnVal;
> > > >                     }
> > > >                 };
> > > > 
> > > >             QueryRunner run = new QueryRunner();
> > > >             List result = (List) run.query(conn, query, mlh);
> > > >             Iterator it1 = result.iterator();
> > > >             while (it1.hasNext()) {
> > > >                 Map map = (Map) it1.next();
> > > >                 Set keys = map.keySet();
> > > >                 Iterator it = keys.iterator();
> > > >                 while (it.hasNext()) {
> > > >                     String key = (String) it.next();
> > > >                     System.out.println(key + ": " + map.get(key));
> > > >                 }
> > > >                 System.out.println();
> > > >             }
> > > >         } catch (Exception e) {
> > > >             System.out.println(e.getMessage());
> > > >             e.printStackTrace();
> > > >         } finally {
> > > >            
> > > > org.apache.commons.dbutils.DbUtils.commitAndCloseQuietly(conn);
> > > >         }
> > > >     }
> > > > 
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> > commons-user-help@jakarta.apache.org
> > > > 
> > > 
> > > 
> > > 
> > > 	
> > > 		
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Photos: High-quality 4x6 digital prints for 25¢
> > > http://photos.yahoo.com/ph/print_splash
> > > 
> > >
> ---------------------------------------------------------------------
> > > 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
> > > 
> > 
> > 
> > 
> > 	
> > 		
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Photos: High-quality 4x6 digital prints for 25¢
> > http://photos.yahoo.com/ph/print_splash
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > 
> 
=== message truncated ===



	
		
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
http://photos.yahoo.com/ph/print_splash

---------------------------------------------------------------------
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