如何在没有时间的情况下将日期插入MySQL数据库表?我尝试了这些代码但是我得到以下异常:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mar 05 00:00:00 GMT-08:00 2014,1,1)' at line 1
Run Code Online (Sandbox Code Playgroud)
注意:在MySQL表中,此列的数据类型我选择了date数据类型
String Date = "\\d\\d\\d\\d\\D[0-1][0-9]\\D[0-3][0-9]";
while (DateMatcher.find()) {
String date = DateMatcher.group().trim();
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date myDate = formatter.parse(date);
db.insert_date(myDate,2,1);
}
Run Code Online (Sandbox Code Playgroud)
我只有日期部分查询插入日期的问题:
// insert DATE
public void insert_date(Date date_str, int sentence_id ,int document_id ){
// Statements allow to issue SQL queries to the …Run Code Online (Sandbox Code Playgroud)