Ricebridge
Search This Site
Sep 08 2008 15:04 UTC

Got a question for us?
Just Ask!


$15 Gift Certificate for every bug you find.

  • Visa MasterCard
  • Visa Delta Laser
  • WorldPay

Bookmark Forum Topic for Ricebridge Java CSV Components at del.icio.us Digg Forum Topic for Ricebridge Java CSV Components at Digg.com Bookmark Forum Topic for Ricebridge Java CSV Components at reddit.com Bookmark Forum Topic for Ricebridge Java CSV Components at YahooMyWeb Bookmark Forum Topic for Ricebridge Java CSV Components at Spurl.net Bookmark Forum Topic for Ricebridge Java CSV Components at Simpy.com Bookmark Polyphasic Mutants at NewsVine Blink this Forum Topic for Ricebridge Java CSV Components at blinklist.com Bookmark Forum Topic for Ricebridge Java CSV Components at Furl.net Fark Forum Topic for Ricebridge Java CSV Components at Fark.com

Topic: ResultSet- writing nulls as ""

Back to Topics Posts RSS Feed
 
I am saving a JDBC resultset to fiile.

Could anyone advise me how I can make all values that are null as "" i.e. as a blank.

Thanks in advance

Q
Q Khawaja Aug 01 2005 14:51
CsvManager saves a ResultSet to a file using the ResultSetLineProvider class. The reason that nulls are not blank is from this line:

field = String.valueOf( iResultSet.getObject( iFieldIndex ) );

in the nextFieldImpl method.
(the source of ResultSetLineProvider is shown in the API documentation).

To change the behaviour of this class, you need create your own ResultSetLineProvider that does what you need - so subclass ResultSetLineProvider, and then say:
csvManager.getCsvManagerStore().setResultSetLineProvider( myResultSetLineProvider );

In your own Provider, use something like:
String field = "";
Object obj = iResultSet.getObject( iFieldIndex );
if( null == obj ) {
field = "";
}
else {
field = String.valueOf(obj);
}

In the next version of CsvManager, I will make this more configurable, so thanks for pointing it out.


Richard Rodger [Ricebridge Staff] Aug 01 2005 15:55
Unfortunately iResultSet and iFieldIndex are private in the super class and are therefore not visible to the subclass
Q Khawaja Aug 02 2005 11:56
Ouch! Good Point - that will have to change.

As a workaround to solve your problem, I would suggest making a full copy of ResultSetLineListener and modifying that, instead of subclassing.

Richard Rodger [Ricebridge Staff] Aug 02 2005 11:59
where can I get the source for this class?
Q Khawaja Aug 02 2005 12:07
scratch that I have got it, thanks
Q Khawaja Aug 02 2005 12:10
In order for the CsvManagerStore.setResultSetLineProvider method to work, you will still need to subclass the original ResultSetLineProvider. Of course, your own class will have the full implementation and not actually use anything from the super-class.
Richard Rodger [Ricebridge Staff] Aug 02 2005 14:41
 
50 Per Page (total: 7)




















comment on this page Home | Search | About Us | Contact Us | Our Products | Documentation | Resources | Login
Copyright © 2004-2008 Ricebridge. All Rights Reserved.