选择存储图像的数据类型
我想使用 java beans 在数据库中存储和检索图像,为此应使用哪种数据类型?
I want to store and retrieve images to/from database using java beans, which data type should be used for this purpose?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最传统的方法是将数据存储在 BLOB 中。这将允许您从 Java 读取和写入字节流,但不允许您在数据库内进行任何转换。
另一种选择是使用 interMedia ORDImage 类型。这通过允许数据库执行诸如生成和返回缩略图、调整压缩质量等操作来提供更大的灵活性。
正如 Grant 所指出的,LONG RAW(以及基于字符的 LONG)数据类型已被弃用,因此您可以不应该使用它们。
The most conventional approach would be to store the data in a BLOB. That would allow you to read and write the byte stream from Java but wouldn't allow you to do any transformation inside the database.
The other alternative would be to use the interMedia ORDImage type. This provides a great deal more flexibility by allowing the database to do things like generate and return a thumbnail image, to adjust compression quality, etc.
As Grant indicates, LONG RAW (and the character-based LONG) data types have been deprecated so you should not be using them.
我认为 BLOB 就是您正在寻找的。 RAW 类型用于遗留支持,因此除非您绝对必须处理它们,否则我不会。
I think BLOB is what you are looking for. RAW types are for legacy support so unless you absolutely have to deal with them I wouldn't.