I have given date type and timestamp data type (4/2/2015 3:10:36 PM) also but I am getting below error. This date I am calling from XLSX sheet.
Exception in thread "main" com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '4/2/2015 3:10:36 PM' for column 'date' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4235)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2825)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379)
at com.tasc.xls.SearchExcel.main(SearchExcel.java:64)
PreparedStatementwith a placeholder? You should be doing something likestatement.setDate(1, dateObj);. If you set it as a string (looks like you are and not parsing it), it's not going to work.