I just downloaded the microsoft jdbc mssql driver to try connect my test app… The lib contains so many methods so I have confused … There is a BLOB and InputStream can be used but I am not sure which one I need to insert FileInputStream for example? I couldn’t find any tutorial showing that, moreover, I want to insert image with t-sql procedure…
So my question is…
How to insert FileInputStream to MS SQL Server 2005 table with Java client app as…
A) With no procedure
B) With t-sql procedure
Any useful tutorial will be much appreciated
There’s an example in the MSDN documentation for the JDBC driver, and a similar example here (found by Googling for “mssql jdbc insert image”). Both of these examples seem to rely on using setBinaryStream() on a PreparedStatement to pass a
FileInputStreaminto a BLOB-type field field.Third example below for reference:
In response to question B, I assume that it’s possible to create a stored procedure with a BLOB parameter and then pass in an input stream using CallableStatement#setBinaryStream very similar to the above, e.g.,