SimpleDateFormat sdf = new SimpleDateFormat(\"yyyyMMddHHmm\");
java.util.Date parsedDate = sdf.parse(\"201212130900\");
java.sql.Timestamp timestamp = new java.sql.Times
Your conversion from string to timestap is OK.(I tested and works).
You problem may be in the time zone or something. Try to use this method instead,
setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
Example:
setTimestamp(1, timestamp , Calendar.getInstance(TimeZone.getTimeZone("UTC")))
UPDATED: (table1.table_key is an CHAR(24))
You should give you date from java in a String, assuming key_value is formatted as "yyyyMMddhhmm"... (for obvious reasons other format will not work)
Other option is in your query convert key_value to TIMESTAMP
Try: (I'm assuming you are working with oracle db, and I do some search)
1) Do a "cast" to timestamp
"select count(*) as counter from table1 where timestamp(table_key) > ?"
2)Using http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions193.htm . I do not know if you can do something like this:
"select count(*) as counter from table1 where TO_TIMESTAMP(table_key,'YYYYMMDDHHMMHH24MI') > ?"