0
這裏是代碼在MySQL中添加java日期的問題?
String DateOfBirth[]=strDOB.split("/");
Date dateOfBirth = new Date();
dateOfBirth.setYear(Integer.parseInt(DateOfBirth[2].trim()));
dateOfBirth.setMonth(Integer.parseInt(DateOfBirth[1].trim()));
dateOfBirth.setDate(Integer.parseInt(DateOfBirth[0].trim()));
java.text.SimpleDateFormat DateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
strDOB = DateFormat.format(dateOfBirth);
DBProcess.QueryExecuter("INSERT INTO patients(patient_id,first_name,last_name,middle_name,birth_dt) VALUES (\""+Double.parseDouble(strPatientID.trim())+"\",\""+strFirstname+"\",\""+strLastname+"\",\""+strMiddlename+"\",\""+strDOB +"\");");
和...究竟是什麼問題?對錯誤的描述(以及預期的行爲)將非常有幫助。 – 2010-08-23 09:18:04
搶常量字符串'INSERT INTO ....'的價值,並直接在MySQL客戶端執行它。它會失敗。然後讓它在該客戶端中工作並將更改應用到您的Java代碼。 – 2010-08-23 09:23:47