在数据库中存储 BLOB 的最佳方式是什么?

发布于 2024-07-09 15:55:57 字数 278 浏览 3 评论 0原文

在编写实用程序脚本以将图像插入数据库时​​,我想知道是否有更绝妙的方法来做到这一点。 最后决定是这样的:

def sql = Sql.newInstance(...)
// ...    
Connection conn = sql.getConnection()
PreparedStatement stmt.prepareStatment(...)
stmt.setBinary(...)
stmt.executeUpate()

一定有更好的方法,有人可以启发我吗?

While writing a utility script to insert images into a database I wondered if there were a groovier way of doing it. In the end settled for something along the lines of this:

def sql = Sql.newInstance(...)
// ...    
Connection conn = sql.getConnection()
PreparedStatement stmt.prepareStatment(...)
stmt.setBinary(...)
stmt.executeUpate()

There must be a groovier way, can someone enlighten me?

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

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

发布评论

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

评论(1

旧竹 2024-07-16 15:55:57

一种“更棒”的方式可能只是存储图像的路径。

将图像存储在目录中并仅将路径存储在数据库中是最好的方法。

A "Groovier" way could be just storing the path were you'd store the images.

Storing the images in a directory and storing just the path in the db is the best way.

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