2

HSQLDB 中有关 MD5 的文档有些稀缺,但我已按照以下说明启用 md5-ing 我的密码:

CREATE FUNCTION md5(VARBINARY(128))
RETURNS VARBINARY(226)
LANGUAGE JAVA
DETERMINISTIC
NO SQL
EXTERNAL NAME 'CLASSPATH:org.hsqldb.lib.MD5.digest'

现在,当我尝试更新密码时:

UPDATE worker SET password = md5('pass123') WHERE wid=1

我收到以下错误:

java.sql.SQLException: routine signature not found for: PUBLIC.MD5(CHARACTER)

我对sql不太熟悉,所以我不确定我在哪里犯了错误。

4

1 回答 1

4

You need a function signature with character strings, rather than binary.

CREATE FUNCTION md5(VARCHAR(128), VARCHAR(10))
RETURNS VARCHAR(256)
LANGUAGE JAVA
DETERMINISTIC
NO SQL
EXTERNAL NAME 'CLASSPATH:org.hsqldb.lib.MD5.encode'

And call the function with a fixed encoding argument:

UPDATE worker SET password = md5('pass123', 'ISO-8859-1') WHERE wid=1
于 2012-05-27T21:10:36.243 回答