Grooviest way to store a BLOB in a database?

寵の児 提交于 2019-12-23 05:11:15

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/324104/grooviest-way-to-store-a-blob-in-a-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!