I have the following code, what I try is to add a PDF to a database. The problem is that I execute the instruction in SQL and it works, but I try to do it with Java and it does not. That is, it always returns a false.
Conexion c = new Conexion();
Connection con= c.getConexion();
if(con!=null){
Statement st;
st = con.createStatement();
String insertar = "INSERT INTO [Documentos](Nombre,Documento) VALUES('FacturaJK9389234',(SELECT * FROM OPENROWSET(BULK N'C:\Datos\"+fileName+"', SINGLE_BLOB) as Pdf))";
out.println("<br />" + insertar );
try{
st.execute(insertar);
agregado=true;
st.close();
}catch(SQLException e){
agregado=false;
e.printStackTrace();
}
}
out.println("<br />" + agregado);
c.cerrarConexion();