Hi I need to insert a tsv file in a table which has a BLOB column. I have written a code in the following way and iam success in this way: 1)Create a file : File file = new File("ex.tsv"); 2)Create a writer : Writer write=null; 3)Assigned the writer as the inputstream for the file. 4)Then inserted data into file 5)Create a prepare statement = pre 6)Insert statement 8)Create a fileinputstream which takes the above file : fin 7)Insert the above created file into the table using pre.setBinaryStream
But the issue is our framework doesnot allows to create file
Is there a way such that without creating file,i insert the data into the BLOB column?
Where does the file come from? In other words, you are getting the TSV file from somewhere. What format is it in? byte, pointer to a file on disk, etc. Step 4 is the one I am confused about. The answer to this will affect the answer to your question.
Thanks for the reply.I would have kept the sample code as my questions are confusing. Anyhow,here is the sample code.
In the above code,while creating a file itself,iam getting security issue as it is directly creating at the server.Later on i understood that iam not supposed to create a file at all (not even in local desk temporarily) but insert the data in the format which i showed above (Line numbers:6 to 10). Is there any way of inserting the same data into BLOB column.Can you send me the sample code.(Not sure: Can we convert into bytes and insert into BLOB.) Please suggest
As Jeanne already said, instead of using a FileInputStream, use an InputStream that is based on the original data. You still didn't say where the original data is coming from, so it's rather difficult to suggest how you might get an InputStream from it. Would you like to explain that?
Joined: Jun 14, 2008
The file is not coming from anywhere.The requirement is to insert the data into the BLOB column in the format i have shown.hence,i tried to create a file.But,as i told you,iam not supposed to create a file.Hence,my question is whether is there any alternate way to insert the data in the same format into BLOB column without creating a file.
Joined: Jun 14, 2008
I solved this issue. If anybody needs assistance,send me a private message