【问题标题】:From a image into my android phone to blob mysql remote database从图像到我的 android 手机到 blob mysql 远程数据库
【发布时间】:2015-06-24 08:20:09
【问题描述】:

我的手机中保存了一张图片,使用的是 android 4.4。

在(图像的)属性中显示位置:“/storage/emulated/0/bluetooth/p.png”。

现在,问题是,我想通过我的 android 应用程序将此图像 (p.png) 上传到远程 mysql 数据库。它有一个名为 photos 的字段,并被定义为 blob。

我正在尝试此代码。但我不工作。它不会给我一个错误,但唱机永远不会出现在我的数据库表中。 (与数据库的连接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 {



        }

}

所以请举例说明如何在我的手机中上传照片并使用blob fild将ir保存在mysql远程数据库中。

【问题讨论】:

    标签: android mysql


    【解决方案1】:

    我认为您应该使用网络服务将您的应用程序与数据库链接起来。

    也许这可以帮助你https://stackoverflow.com/a/15173589/4364031

    【讨论】:

    • 感谢您的回答。但是将我的应用程序连接到数据库没有问题。
    猜你喜欢
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    • 2014-02-19
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    • 2011-11-06
    • 2015-07-06
    相关资源
    最近更新 更多