编译时收到的错误消息是“日期时间值的字符串表示形式的语法不正确”
从 History ArrayList 传入日期对象时,其格式为 '19-Apr-2013'
我知道数据库的格式是“年-月-日”。有什么方法可以将我的日期对象转换为数据库的正确格式?
for ( Patient p: pList )
{
patientInsertSQL = "Insert Into SHAUN.PATIENT VALUES (" + p.getPatientNum() +
+ ", '" + p.getPatientName() + "', '" + p.getPatientAddress() + "', '"
+ p.getPatientPhone() + "')";
res = stmt.executeUpdate(patientInsertSQL);
System.out.println(res);
ArrayList<History> tempHistList = p.getHistory();
String histSelect = "select * from SHAUN.HISTORY";
result = stmt.executeQuery(histSelect);
for ( History h: tempHistList )
{
historyInsertSQL = "Insert Into SHAUN.HISTORY VALUES (" + h.getHistID()
+ ", '" + h.getConditionName() + "', '" + h.getMedication() + "', '"
+ h.getDateOccured() + "', " + p.getPatientNum() + ")";
res = stmt.executeUpdate(historyInsertSQL);
System.out.println(res);
//Loop Checker
int i = 1;
System.out.println("In the History Loop " + i);
i++;
}
System.out.println("In the loop!");