This content has been marked as final. Show 7 replies
Use a PreparedStatement. Then come back.
(I don't believe that Timestamp.toString() yields a usable value.)
Using single-quotes, i get this error:
INSERT INTO myTable (colString, myTime) VALUES ('hello', '2006-11-28 09:17:50.0') java.sql.SQLException: La conversione del tipo di dati da char a datetime ha generato un valore di tipo datetime non compreso nell'intervallo dei valori consentiti.
The conversion of the data type from char to datetime generated a vale of datetime value not within the interval of the permitted values.
Read what CeciNEstPasUnProgrammeur said.
You shouldn't handle escaping and conversion. Let the driver do that instead. Use a PreparedStatement.
This is more like an SQL question than a Java question.
Your problem is with the date formatting of your DBMS itself.
SQL offers many functions that could convert your string to the date format it is expecting. Once you know that format you just parse the date you have in your application and present it to your server in the format it needs.
Hint: First try to insert a date manually to your server to find the correct format.
This is more like an SQL question than a JavaNo it's a JDBC question, and the OP should still use a PreparedStatement. It will handle the conversion to the correct database format.
Thanks, using Prepared Statement, now it worked !
Gimme all your dukes now. ;)