开发者

SetDate with Statement?

With PreparedStatemen开发者_高级运维t, you just call SetDate and be done with it.

How do you pass in a Date with a regular Statement?


It depends on the DBMS you are using, each one can use a different format for date literals.

For example in Oracle, you use:

UPDATE table SET DATEFIELD = DATE '1998-12-25'

In MySQL:

UPDATE table SET DATEFIELD = '1998-12-25'

Etc.

I would recommend to continue using PreparedStatement to avoid SQL Injection attacks.


You just construct the regular statement using the string and the function provided by DBMS to convert a string to the date .

Most DBMS should have such function .For example , Oracle have a to_date() .( eg: to_date('2012/01/02', 'yyyy/mm/dd') .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜