I have this part of select
to_date(?,'YYYY-MM-DD HH24:MI:SS')
and set param from java
stmt.setString(2, startDate);
but my startDate
is String (2016-07-13 00:00:00) and I need this result
to_date('2016-07-13 00:00:00','YYYY-MM-DD HH24:MI:SS')
I can make this
stmt.setString(2, "\'"+startDate+"\'");
But I think it is bad practic.
Can I make something like this
to_date('?','YYYY-MM-DD HH24:MI:SS')
or
to_date(\\'?\\','YYYY-MM-DD HH24:MI:SS')
or something else?
This is a copy of Oracle Documentation :
void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
Sets the designated parameter to the given java.sql.Date value, using the given Calendar object. The driver uses the Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.