This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing the ResultSet

 
Goldie
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a way where I can store the result of the query as a InputStream rather than a string. The reason for me to store it as InputStream is that .. the method I am using to process the resultset accepts inputstream only.
right now I have to save the data of the resultset as a file and then get the data from the file in the same program.
Could anyone pls help me
Thanks
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need to pass the entire ResultSet as one Stream then you can build a String and then create a java.io.StringBufferInputStream object.
If you want to pass individual columns then you can use either ResultSet.getAsciiStream() or ResultSet.getBinaryStream(). Both of those will take only one column at a time specified by using either an int (column number) or String (column name).
 
Susan Hoover
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would something like this work?

Susan
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that the creation of a new ByteArrayInputStream is inside the while loop. bais will end up only with data from the last row. How about something like this. I didn't get a chance to try it out but I think it should work.


[This message has been edited by Thomas Paul (edited January 11, 2001).]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic