Skip to Content
0
Former Member
Jun 13, 2005 at 12:49 PM

date timestamp format and JDBC

136 Views

hi,

i have a table which contains the data type and timestamp type. I am setting up prepared statements - however i have difficulties getting the date right.

I searched help.sap.com and found this code:

import  java.sql.SQLException;

 
String dateString = "2003-03-24";

java.sql.Date date = new java.sql.Date.valueOf(dateString);

PreparedStatement stmt =

   conn.prepareStatement("insert into RESERVATION "

                  + "(ID,  RESERVATION_DATE)"

                  + "values (23, ?)");

try {

   stmt.setDate(1, date);

   stmt.executeUpdate();

} finally {

   stmt.close();

}

i've got the import correct and tried the code but i get the "cannot be resolved or type" error.

How do I get that straight?

thanx in advance, matthias