I am doing this:

Select count(*) from table1 t where start_datetime = datetime(?);

Setting datetime using:

ps.setString("01-01-2010 12:12:00.123")

It is giving error as : Non numeric character in datetime or interval.

But if I run this as SQL in SQL Editor it works all fine.

Any clues how to correct this ?

有帮助吗?

解决方案

Change around the string to conform to the default datetime date pattern

ps.setString("2010-01-01 12:12:00.1230")

I think something like this should also work

select count(*) from table1 t 
               where start_datetime = TO_DATE(?,"%Y-%m-%d %H:%M:%S %F3")

Let me know

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top