@ Test
Public void testHistoryData () throws a ParseException {
The DateFormat format=new SimpleDateFormat (" MM - dd yyyy - HH: MM: ss ");
The Date startDateTime=format. The parse (" 2020-04-01 00:00:00 ");
The Date endDateTime=format. The parse (" the 2020-04-01 05:00:00 ");
List
"Baseline_32_171", startDateTime,
EndDateTime);
Data. The forEach (s - & gt; {
System.out.println(s);
});
}
Mapper interfaces are as follows:
List
@ Param (" startDateTime ") Date startDateTime,
@ Param (" endDateTime ") Date endDateTime
);
The XML file is as follows:
ResultMap="BaseResultMap" statementType="STATEMENT" & gt;
Select * from ${tableName}
Where a DateTime
Between # {startDateTime}
And # {endDateTime}
But the Java background error:
# # # Error querying the database. Cause: the 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 '?
The and? 'at line 6
# # # The error may exist in wnlbswit/SSM/mapper/BaselineMapper. XML
# # # The error may involve wnlbswit. SSM. Mapper. BaselineMapper. FindByTableName1
# # # The error occurred while executing a query
# # # SQL: select * from baseline_32_171 - where a DateTime & gt;=? - and DateTime & lt;=? Where a DateTime between? The and?
# # # Cause: 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 '?
The and? 'at line 6
; Bad SQL grammar []; Nested exception is 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 '?
The and? 'at line 6
Could you tell me where is the problem! Feel the XML files do not have what problem, who can help me with it
CodePudding user response:
BETWEENDATE_FORMAT (# {startDateTime} '% % Y - m - H: % d % % I: % s')
AND
DATE_FORMAT (# {endDateTime} '% % Y - m - H: % d % % I: % s')
CodePudding user response:
select * from baseline_32_171 - where a DateTime & gt;=? - and DateTime & lt;=? Where a DateTime between? The and?
Why logging of SQL with "-- where a DateTime & gt;=? - and DateTime & lt;=?" This is a piece of
CodePudding user response: