1 ### Error querying database. 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 '}' at line 6 2 ### The error may exist in file [D:\workspace\eclipse\Contact\target\classes\com\cmbc\mapper\ContactMapper.xml] 3 ### The error may involve com.cmbc.dao.ContactMapper.queryByNamePassword-Inline 4 ### The error occurred while setting parameters 5 ### SQL: select id, name, password, sex, birthday, address from contact where name = ? and password= ?} 6 ### 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 '}' at line 6 7 ] 8 [org.mybatis.spring.SqlSessionUtils]Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@143aaff8] 9 [org.springframework.jdbc.datasource.DataSourceUtils]Returning JDBC Connection to DataSource 10 [org.springframework.test.context.support.DirtiesContextTestExecutionListener]After test method: context [[TestContext@5d1f72db testClass = TestContactMapper, testInstance = com.cmbc.test.TestContactMapper@3badb7a0, testMethod = testQueryByNamePassoword@TestContactMapper, testException = org.springframework.jdbc.BadSqlGrammarException: 11 ### Error querying database. 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 '}' at line 6 12 ### The error may exist in file [D:\workspace\eclipse\Contact\target\classes\com\cmbc\mapper\ContactMapper.xml] 13 ### The error may involve com.cmbc.dao.ContactMapper.queryByNamePassword-Inline 14 ### The error occurred while setting parameters 15 ### SQL: select id, name, password, sex, birthday, address from contact where name = ? and password= ?} 16 ### 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 '}' at line 6 17 ; 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 '}' at line 6, mergedContextConfiguration = [MergedContextConfiguration@b7e2544 testClass = TestContactMapper, locations = '{classpath:spring.xml, classpath:spring-mybatis.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader']]], class dirties context [false], class mode [null], method dirties context [false]. 18 [org.springframework.test.context.web.ServletTestExecutionListener]Resetting RequestContextHolder for test context [TestContext@5d1f72db testClass = TestContactMapper, testInstance = com.cmbc.test.TestContactMapper@3badb7a0, testMethod = testQueryByNamePassoword@TestContactMapper, testException = org.springframework.jdbc.BadSqlGrammarException: 19 ### Error querying database. 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 '}' at line 6 20 ### The error may exist in file [D:\workspace\eclipse\Contact\target\classes\com\cmbc\mapper\ContactMapper.xml] 21 ### The error may involve com.cmbc.dao.ContactMapper.queryByNamePassword-Inline 22 ### The error occurred while setting parameters 23 ### SQL: select id, name, password, sex, birthday, address from contact where name = ? and password= ?} 24 ### 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 '}' at line 6
<select id="queryByNamePassword" resultMap="BaseResultMap" parameterType="java.lang.String"> select <include refid="Base_Column_List" /> from contact where name = #{0} and password= #{1}} </select>
Contact queryByNamePassword(String name, String password);
xml 里面多了个}
谢谢你,我前面已经找到了。因为最近比较忙所以就没有上来博客园看。你说的没有错,xml里面多了个大括号
@远歌: 嗯嗯,找到了就好
@胖胖的半山兄: 以后不懂的还希望多多指教
@远歌: 相互学习吧~