aspose file tools*
The moose likes JDBC and the fly likes Storing the ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Storing the ResultSet" Watch "Storing the ResultSet" New topic
Author

Storing the ResultSet

Goldie
Greenhorn

Joined: Dec 28, 2000
Posts: 11
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

Joined: May 05, 2000
Posts: 13974
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).


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Susan Hoover
Ranch Hand

Joined: Jan 04, 2001
Posts: 64
Would something like this work?

Susan
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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.
 
subject: Storing the ResultSet