This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a text file whose data I convert to a bytearray and thereafter want to save the bytearray to an IMAGE datatype in a sql-server table. The intention is to let the users download this file later on from the internet. Currently I am able to use the IMAGE datatype successfully in the above fashion for storing & retrieving PDF files (i.r. uploading a PDF file as a bytearray for uploading into the table and lateron while retrieving, I ready the bytearray with the setContentType in my servlet="application/pdf". But, it doesn't work for the text file. I am using the following code in the servlet to download the data: response.setContentType ("application/x-filler"); The data in the downloaded file looks like this: [B@2dce4f48 The data when originally uploaded from a text file was actually: Doe, John, E. My question is: - Is it possible to use IMAGE datatype for storing bytearray obtained from converting text data? Or do I have to create a separate TEXT datatype field. - I am using opta2000 drivers for JDBC connectivity. I have observed that when I am try to upload the byte array to the IMAGE datatype, it complains if I don't have quotes around the bytearray (and the update query fails). I ultimately saved the bytearray after enclosing it within quotes. I have a feeling that this may be resulting in the data being saved as text rather than as a bytearray. Any thoughts would be gratefully appreciated. Thanks