我嘗試讀出表並將其寫入csv文件。Java + mySQL:以字符串形式讀取日期
while (rs2.next())
{
Enumeration<String> en = sqlfields.keys();
while (en.hasMoreElements())
{
String field = en.nextElement();
String value = rs2.getString(field);
bw.write(Kapseln + value + Kapseln + Trennzeichen);
}
bw.newLine();
cur++;
}
但如果字段類型:日期時間,我得到這個錯誤信息:
java.sql.SQLException: Cannot convert value
'0000-00-00 00:00:00' from column 12 to TIMESTAMP.
爲什麼Java的嘗試轉換爲時間戳?
我喜歡得到的值作爲字符串=>rs2.getString(field)
http://stackoverflow.com/questions/782823/handling-datetime-values-0000-00-00-000000-in-jdbc – Vipul