Please use code tags when posting code. I would normally add here that one of the reasons to do so it they preserve the formatting of the code but as you haven't used any indentation etc they haven't really helped in this case. In future please indent your code in a consistent manner as it makes reading the code so much easier.
could you provide inputs here to read the n rows at a time from the result set ...
I don't know what you mean by this as you are reading 50 rows and then writing the block of data out.
Some questions:
Why have a for-each header loop and then use an index rather than the header name - why not just have a for loop from 0 to i < header.length?
Why are you writing the data as bytes?
Why are you declaring the variable screenPix and assigning an array to it which will then be discarded on the next line?
What happens to the last n rows of data if the result set isn't exactly divisible by 50?
You may need to do some performance
testing with a compression output stream to find if there are any efficiency advantages with writing larger blocks of data, if not you could just write a line at a time.