I have a image save in me phone with android 4.4 .
In properties (of the image) says location:"/storage/emulated/0/bluetooth/p.png".
Now, the problem is, I wanna uploading this image (p.png) by my android applicacion to a remote mysql database. It has a field calls photos and is definied as blob.
I´m trying this code. but i dont works. it doesnt give me an error, but the phono never appears in the table of my database. (the coneccion with database is OK).
public void setImage() throws Exception
{
crearConexion();
System.out.println("Entre");
String q="insert into clientes(imagen) values (?) where id_cliente=1;";
try {
String filePath = "/storage/emulated/0/bluetooth/p.png";
InputStream inputStream = new FileInputStream(new File(filePath));
PreparedStatement statement = con.prepareStatement(q);
statement.setBlob(1, inputStream);
statement.executeUpdate();
System.out.println("Terminee");}
catch (Exception e) {
System.out.println(e.getMessage());
System.out.println("ERROR SQLlogHA");
} finally {
}
}
So please give an example of how upload a photo in my phone and save ir in mysql remote data base with a blob fild.