-1
我想從eclipse java程序中將日期保存到oracle。 現在我使用此代碼如何將日期保存到oracle
DateFormat dt=new SimpleDateFormat("MM/dd/yyyy");
java.sql.Date dob=(java.sql.Date)dt.parse("02/02/2015");
ob.setDateOfBirth(dob);
表有一個名爲DATE_OF_BIRTH有日期數據類型列。
但我得到一個錯誤
Exception in thread "main" java.lang.ClassCastException:
java.util.Date cannot be cast to java.sql.Date
at com.TestCustomerDao.main(TestCustomerDao.java:22)
請幫助
'dt.parse(「02/02/2015」);'此方法將返回java.util.Date'對象。你只能使用那一個.. – Prashant
其他副本和類似的:[this](http://stackoverflow.com/q/18893863/642706),[this](http://stackoverflow.com/q/24652571/642706 ),[this](http://stackoverflow.com/q/28292468/642706),[this](http://stackoverflow.com/q/2942270/642706)和**最重要**,[java .util.Date vs java.sql.Date](http://stackoverflow.com/q/2305973/642706)。 –