【发布时间】:2019-10-29 11:45:25
【问题描述】:
使用 CodenameOne Web 数据库扩展,我可以获得基本的 SQL 字段来处理字符串和数字,但不能用于大型二进制对象 BLOB。我按照这里的说明进行操作:https://www.codenameone.com/blog/connecting-to-a-mysql-database-part-2.html CodenameOne 是否支持 BLOB?如果是这样,你怎么做?我找不到任何使用 BLOB 类型的示例。
我尝试过使用长字符串,使用 MarianaDB,可以得到高达 512K 的字符串大小,但我需要存储更大的图像。
MariaDB [(none)]> 使用 tsg;描述照片; 数据库已更改 +------------+------------------+------+-----+---- -----+----------------+ |领域 |类型 |空 |钥匙 |默认 |额外 | +------------+------------------+------+-----+---- -----+----------------+ |编号 | int(10) 无符号 |否 |优先级 |空 |自动增量 | | player_id |整数(11) |否 | |空 | | | tree_id |整数(11) |否 | |空 | | |照片类型 |长文 |否 | |空 | | |图片 |斑点 |是 | |空 | | +------------+------------------+------+-----+---- -----+----------------+ 一组 5 行(0.001 秒)
当我添加没有 blob 的记录时,它可以工作:
m.put("playerId", "1");
m.put("treeId", "2");
m.put("photoType", "front");
m.put("image", null);
client.create(m, res -> {
System.out.println(m);
System.out.println("create result = " + res);
});
输出: {treeId=2, image=null, photoType=front, playerId=1} 创建结果 = true
但是当我尝试添加 blob 时,它没有:
m.put("playerId", "1");
m.put("treeId", "2");
m.put("photoType", "front");
byte bytes[] = new byte[100];
m.put("image", bytes);
client.create(m, res -> {
System.out.println(m);
System.out.println("create result = " + res);
});
输出:
{treeId=2, image=[B@5968c8cb, photoType=front, playerId=1} 创建结果 = false
帮助!我用错了 BLOB,还是 CN1 不支持 BLOB?
唯一的错误消息来自 create 为 false 的结果。
【问题讨论】:
标签: mysql netbeans glassfish codenameone