List of usage examples for java.sql CallableStatement setBinaryStream
void setBinaryStream(String parameterName, java.io.InputStream x, long length) throws SQLException;
From source file:it.greenvulcano.gvesb.datahandling.dbo.DBOCallSP.java
/** * @param cs/*from w w w .ja v a2s. c om*/ * @param bais * @param length * @throws SQLException */ private void setBinaryStream(CallableStatement cs, ByteArrayInputStream bais, int length) throws SQLException { if (useName) { cs.setBinaryStream(currName, bais, length); } else { cs.setBinaryStream(colIdx, bais, length); } }
From source file:sd_conexion_bd.Servicios.java
public void registrar_usuario(String nombre, String apellido, String ciudad, String user, String pass, String foto) throws ClassNotFoundException, SQLException, FileNotFoundException { //System.out.println(nombre + apellido + ciudad + user + pass + foto); this.conectar("localhost:3306", "mensajeria", "mensajeria", "1234"); //this.conectar("192.168.43.21:3306", "mensajeria","mensajeria","1234"); String sql = "{call registrar_usuario(?, ?, ?, ?, ?, ?)}"; CallableStatement cstmt = conexion.prepareCall(sql); cstmt.setString(1, nombre);/* w w w.j a v a 2 s.c om*/ cstmt.setString(2, apellido); cstmt.setString(3, ciudad); cstmt.setString(4, user); cstmt.setString(5, pass); File file = new File(foto); FileInputStream inputStream = new FileInputStream(file); cstmt.setBinaryStream(6, inputStream, (int) file.length()); //cstmt.setBlob(6, inputStream); cstmt.execute(); }