Problem: I can't update a date value.
=====================================
Reading the date from the database and putting it to a JText field works
well:
try {Datum.setText(dateFmt.format(rs.getDate("Datum")));}
catch(Exception eDatum){Datum.setText("");}
Checking if the new value (typed in) is valid works fine:
try
java.util.Date date = dateFmt.parse(Datum.getText());
}
catch(ParseException fopaexDatum)
Datum.setText("");
}
catch(IllegalArgumentException foarexDatum)
Datum.setText("");
}
But when I try to update the String containing the date to the database I
get errors:
1) rs.updateString("Datum" , Datum.getText());
runtime error (as expected):
java.sql.SQLException: Arithmetic overflow error converting expre
ssion to data type datetime.
at com.inet.tds.e.a(Unknown Source)
at com.inet.tds.d.if(Unknown Source)
at com.inet.tds.d.updateRow(Unknown Source)
at DataForm00.updateData(DataForm00.java:202)
2) java.sql.Date date = dateFmt.parse(Datum.getText());
causes compile error:
196: Incompatible type for declaration.
Explicit cast needed to convert java.util.Date to java.sql.Date.
3) java.sql.Date date = (java.sql.Date)dateFmt.parse(Datum.getText());
rs.updateDate("Datum" , date);
causes runtime error (no chance!):
java.lang.ClassCastException: java.util.Date
at DataForm00.updateData(DataForm00.java:196)
at DataNavPanel.actionPerformed(DataNavPanel.java:225)
Please help me. How do I have to format the String containing the date to
update it successfully?
I tried to find answers in all the documentation I have (books, newsgroups,
examples),
but all I could find ist updateString and updateInt which works fine
allready.
Please give me a hint or the sollution :-)
best regards
Christoph Wohlan