我是刚接触ibatis的,在我进行insert语句测试的时候发生如下情况
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 'desc) values(10,'hello','desc')' at line 1我的xml代码:<resultMap class="org.ibatis.test.Student" id="StudentResult">
<result column="id" property="id" jdbcType="int"></result>
<result column="name" property="name" jdbcType="varchar"/>
<result column="desc" property="desc" jdbcType="varchar"/>
</resultMap>
<insert id="insertStudent" parameterClass="org.ibatis.test.Student">
insert into student(id,name,desc) values(#id#,#name#,#desc#)
</insert>
我的java代码:
IbatisTest ibatis = new IbatisTest();

try {
ibatis.SqlMapClient.startTransaction();
Student student = new Student();
student.setId(new Integer(10));
student.setName("hello");
student.setDesc("desc");

ibatis.insert(student);
ibatis.SqlMapClient.commitTransaction();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}我想问下,ibatis 在拿到sql语句参数并进行拼接的时候,其实sql语句本身也被当做字符串在数据库执行的
我们可以看见在 values(10,'hello','desc')'在括号后面有个引号,如果出现这种情况我们改如何解决这种引号冲突j2ee;java;java Webibatis