org.h2.jdbc.JdbcSQLException: Cannot parse date constant ?676-10-10,
cause: java.lang.NumberFormatException: For input string: "?676"; SQL
statement:
Caused by: java.lang.NumberFormatException: For input string: "?676"
Note: ? is box (somehow unable to copy paste the symbol in here)
What cause this error??
Why when I insert the invalid date and backup, there is no error, but
when i restore there is an error?
Why not when I insert the invalid date and backup, it shows the error
too..?
How should I do to restore this broken sql backup?
The problem is that java.sql.Date.toString() doesn't support years
beyond 9999. You will get the same or a similar result using:
System.out.println(java.sql.Date.valueOf("19676-01-01").toString());
However I will implement a workaround in H2, so that the following
test will work:
Connection conn;
conn = DriverManager.getConnection(
"jdbc:h2:data/test", "sa", "sa");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("call date '19676-12-23'");
rs.next();
Timestamp ts = rs.getTimestamp(1);
System.out.println(ts);
java.sql.Date d = rs.getDate(1);
System.out.println(d); // can't be fixed
System.out.println(rs.getString(1));
The next version of H2 will print:
19676-12-23 00:00:00.0
see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6898593
Since Java 6u18 java.sql.Date.valueOf() throws exceptions if not in
yyyy-mm-dd format. I just checked in a fix for RandomGen.randomDate().
You should check if everywhere else the handling is correct.
Regards
Christian
On Mar 31, 8:28 pm, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:
On Apr 1, 2:55 am, Christian Peter <christian.peter...@googlemail.com>
wrote:
> Hi Thomas,
>
> seehttp://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6898593