黑莓数据库上的图像存储问题

发布于 2024-10-16 13:23:31 字数 229 浏览 0 评论 0原文

我在我的 BlackBerry 移动应用程序中使用 SQLite 数据库,并且运行良好。

我想将相机捕获的图像保存到数据库中。相机捕获图像的大小是400k,但我将其缩小到7000字节。

当我尝试将其插入数据库时​​,它显示Blob 大小太大。数据库每次查询仅接受最多 4000 字节。

我怎样才能插入这张图片?有人可以指导我吗?

I am using SQLite database in my BlackBerry mobile application and it works fine.

I want to save a camera capture image to the database. The size of the camera capture image is 400k, but I reduce it to 7000 bytes.

When I am trying to insert it into the database, it shows Blob size is too Big. The database accepts only up to 4000 bytes per query.

How can I insert this image? Could anyone guide me please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海之角 2024-10-23 13:23:31

虽然一般来说SQLite 对 BLOB 有相当合理的限制,但事情是在 Blackberry 上受到更多限制。 (该限制实际上是在编译数据库引擎时设置的。)您可以使用第一页上的信息来实际找出限制的真正含义(但请注意,这可能会因 Blackberry 平台而异;这一点已注意到)在第二页上):

int sizeLimit = sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1);

但是,第二个链接确实指出,最好在数据库中存储尽可能少的数据(好吧,要合理;如果需要数据,就应该在)与其余的作为普通文件存储的信息。对于图像,我建议将图像本身放入文件中,并仅将元数据(当然包括文件名!)保留在数据库中。这将解决大小限制,同时仍然允许相当丰富的查询。这样做会损失图像数据的事务存储(但如果您获得的回报是能够存储数据,那仍然是一笔不错的交易)。

While in general SQLite has pretty reasonable limits on BLOBs, things are much more constrained on a Blackberry. (The limit is really set at the time of compilation of the DB engine.) You can use the information on the first page to actually find out what the limit really is (though be aware that this may vary between Blackberry platforms; this is noted on the second page):

int sizeLimit = sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1);

However, the second link does note that it is good practice to store as little data in the DB as possible (well, be reasonable; if data needs to be in, it should be in) with the rest of the information stored as normal files. In the case of images, I'd suggest putting the image itself in a file and keeping only metadata (including the filename, naturally!) in the database. That'll work around the size limits while still allowing reasonably rich queries. What you lose by doing this is transactional storage of the image data (but if what you are gaining in return is the ability to store the data at all, that's still a good trade).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文