问题
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