I've written a program that needs to insert data that includes a timestamp column into HANA using a jdbc connection. This insert fails every time with com.sap.db.jdbc.exceptions.jdbc40.SQLDataException: [303]: invalid DATE, TIME or TIMESTAMP value: Error while parsing DATE/TIME at function to_timestamp(). The code produces SQL that will run in HANA in a SQL session.
code sample
...
private static final String INSERT_STW = "insert into STW.STWS values(?,?,?,TO_TIMESTAMP(?,'YYYY-MM-DD HH24:MI:SS.FF3'),?,?,?,?,new ST_POINT(?,?))";
PreparedStatement prepStatement = con.prepareStatement(INSERT_STW);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String format1 = "'" + format.format(createdAt) + "'"; // createdAt has value Fri May 09 14:13:49 EDT 2014 and produces format1 = '2014-05-09 14:13:49.000'
prepStatement.executeUpdate();
produces this SQL which will insert using a SQL connection to HANA
insert into STW.STWS values(464830615054217217,'en',2305754499,TO_TIMESTAMP( '2014-05-09 14:13:49.000','YYYY-MM-DD HH24:MI:ss.FF3'),'GB',0,'@jade46_ ict is hard okay',0,new ST_POINT( -0.35978946,52.78673714))
Thank you in advance for any help.
Wayne