aspose file tools
The moose likes JDBC and the fly likes Storing the ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply 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).]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Storing the ResultSet
 
Similar Threads
Saving InputStream to File
storing images in database and retreiving it
to store the form data temporarily at client side
problem uploading file in oracle databse
passing ResultSet from servlet to applet