`
flyeagle
  • 浏览: 213311 次
  • 来自: ...
社区版块
存档分类
最新评论

mybatis java.sql.SQLException: ORA-00907: 缺失右括号

阅读更多

 

 在使用spring+mybatis进行应用开发时,使用了mybatis的动态SQL,添加动态查询语句:

 

<select id="getSpasDataLogList"  resultType="com.xxx.xxx.xxxBean" resultMap="spasDataLogMap">
	 <![CDATA[ 
      select * from t_table where datetime > #to_DATE(#{startDate}, 'yyyy-mm-dd')
       <if test="datafrom!= null and datafrom!= ''"> AND a.datafrom like #{datafrom} </if>
	   ]]> 
</select>

 添加动态查询语句: 

<if test="datafrom!= null and datafrom!= ''"> AND a.datafrom like #{datafrom} </if> 

   报java.sql.SQLException: ORA-00907: 缺失右括号  错误。去除

<if test="datafrom!= null and datafrom!= ''"> AND a.datafrom like #{datafrom} </if> 

 后可以正常执行,原来添加

<![CDATA[ ]]> 

后解析器不对它进行解析<if>不会当mybatis的标签解析,而是以大于符号和小于符号进行解析,所以报错。去除

<![CDATA[ ]]> 

但是,去除<![CDATA[ ]]> 后,发现

datetime > #to_DATE(#{startDate}, 'yyyy-mm-dd')

又报错,需要对大于符号进行转义,修改成:

 

datetime &gt; #to_DATE(#{startDate}, 'yyyy-mm-dd')

问题解决。

转义表:

> &gt; 大于
< &lt; 小于
& &amp;
>= &gt;= 大于等于
<= &lt;= 小于等于

 

 

 

 

 

分享到:
评论

相关推荐

    Mybatis出现ORA-00911: invalid character的解决办法

    今天在项目中,使用Mybatis对oracle数据库进行操作的时候,报出ORA-00911: invalid character的错误,检查了一下SQL,发现都书写正确啊,复制到plsql上执行也都没问题,这什么原因呢? 注意:这里说的是用navicat...

    MySQL存储表情时报错:java.sql.SQLException: Incorrect string value:‘\xF0\x9F\x92\xA9\x0D\x0A...’的解决方法

    主要给大家介绍了关于MySQL存储表情时报错:java.sql.SQLException: Incorrect string value: 'xF0x9Fx92xA9x0Dx0A...'的解决方法,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。

    mybatis-spring-boot-autoconfigure-1.3.2-API文档-中文版.zip

    赠送jar包:mybatis-spring-boot-autoconfigure-1.3.2.jar; 赠送原API文档:mybatis-spring-boot-autoconfigure-1.3.2-javadoc.jar; 赠送源代码:mybatis-spring-boot-autoconfigure-1.3.2-sources.jar; 赠送...

    mybatis-spring-boot-autoconfigure-2.1.1-API文档-中英对照版.zip

    赠送jar包:mybatis-spring-boot-autoconfigure-2.1.1.jar; 赠送原API文档:mybatis-spring-boot-autoconfigure-2.1.1-javadoc.jar; 赠送源代码:mybatis-spring-boot-autoconfigure-2.1.1-sources.jar; 赠送...

    mybatis-spring-boot-autoconfigure-2.1.1-API文档-中文版.zip

    赠送jar包:mybatis-spring-boot-autoconfigure-2.1.1.jar; 赠送原API文档:mybatis-spring-boot-autoconfigure-2.1.1-javadoc.jar; 赠送源代码:mybatis-spring-boot-autoconfigure-2.1.1-sources.jar; 赠送...

    mybatis-generator-maven-plugin-1.4.0.jar

    java运行依赖jar包

    mybatis-spring-2.0.3-API文档-中文版.zip

    赠送jar包:mybatis-spring-2.0.3.jar; 赠送原API文档:mybatis-spring-2.0.3-javadoc.jar; 赠送源代码:mybatis-spring-2.0.3-sources.jar; 赠送Maven依赖信息文件:mybatis-spring-2.0.3.pom; 包含翻译后的API...

    mybatis-3.5.9-API文档-中文版.zip

    赠送jar包:mybatis-3.5.9.jar; 赠送原API文档:mybatis-3.5.9-javadoc.jar; 赠送源代码:mybatis-3.5.9-sources.jar; 赠送Maven依赖信息文件:mybatis-3.5.9.pom; 包含翻译后的API文档:mybatis-3.5.9-javadoc-...

    mybatis3.5.7.zip

    MyBatis 是一款优秀的持久层框架,它支持自定义 SQL、存储过程以及高级映射。MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作。MyBatis 可以通过简单的 XML 或...mybatis-3-mybatis-3.5.7.tar.gz

    mybatis-config.xml

    application.properties配置: #mybatis mybatis.config-location=classpath:mybatis-config.xml mybatis.check-config-location=true mybatis.mapper-locations=classpath:mappers/*.xml

    mybatis-spring-2.0.6-API文档-中文版.zip

    赠送jar包:mybatis-spring-2.0.6.jar; 赠送原API文档:mybatis-spring-2.0.6-javadoc.jar; 赠送源代码:mybatis-spring-2.0.6-sources.jar; 赠送Maven依赖信息文件:mybatis-spring-2.0.6.pom; 包含翻译后的API...

    idea free-idea-mybatis-2019.12.18插件

    本文将详细介绍一款名为"idea free-idea-mybatis-2019.12.18"的插件,该插件专为IDEA设计,旨在优化MyBatis框架的开发体验。 首先,MyBatis是一款轻量级的持久层框架,它通过简化SQL操作,使得Java开发者能够更专注...

    mybatis-spring-2.0.0-API文档-中文版.zip

    赠送jar包:mybatis-spring-2.0.0.jar; 赠送原API文档:mybatis-spring-2.0.0-javadoc.jar; 赠送源代码:mybatis-spring-2.0.0-sources.jar; 赠送Maven依赖信息文件:mybatis-spring-2.0.0.pom; 包含翻译后的API...

    Mybatis-ehcache 1.2.1源码(ehcache-cache-mybatis-ehcache-1.2.1.zip)

    Mybatis-ehcache 1.2.1 是一个集成Mybatis和Ehcache的缓存模块,用于提高Mybatis框架的查询效率。Ehcache是一个广泛使用的Java缓存解决方案,它能够有效地存储和检索数据,减少数据库的负载,提高应用程序性能。在...

    mybatis-3.5.7-API文档-中文版.zip

    赠送jar包:mybatis-3.5.7.jar; 赠送原API文档:mybatis-3.5.7-javadoc.jar; 赠送源代码:mybatis-3.5.7-sources.jar; 赠送Maven依赖信息文件:mybatis-3.5.7.pom; 包含翻译后的API文档:mybatis-3.5.7-javadoc-...

    数据库疑难杂症 java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual tha

    数据库疑难杂症 java.sql.SQLSyntaxErrorException: 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 ‘order’ at line...

    mybatis-3.5.3-API文档-中文版.zip

    赠送jar包:mybatis-3.5.3.jar; 赠送原API文档:mybatis-3.5.3-javadoc.jar; 赠送源代码:mybatis-3.5.3-sources.jar; 赠送Maven依赖信息文件:mybatis-3.5.3.pom; 包含翻译后的API文档:mybatis-3.5.3-javadoc-...

    mybatis-plug.jar和 mybatis-plug的安装说明

    1. **简化SQL编写**:MyBatis-Plus提供了CRUD操作的便捷方法,无需手动编写复杂的SQL语句。 2. **自动化事务管理**:它能自动处理事务提交和回滚,减轻了开发者对事务管理的负担。 3. **内置高性能分页插件**:支持...

    mybatis-spring-2.0.6-API文档-中英对照版.zip

    赠送jar包:mybatis-spring-2.0.6.jar; 赠送原API文档:mybatis-spring-2.0.6-javadoc.jar; 赠送源代码:mybatis-spring-2.0.6-sources.jar; 赠送Maven依赖信息文件:mybatis-spring-2.0.6.pom; 包含翻译后的API...

    MyBatis和Spring整合jar:mybatis-3.2.7.jar等

    2. **MyBatis-Spring**:mybatis-spring-1.2.2.jar是MyBatis和Spring之间的桥梁,它实现了两者的无缝集成,让开发者可以利用Spring的依赖注入和事务管理特性,同时享受MyBatis的灵活SQL操作。 这个jar包提供了一些...

Global site tag (gtag.js) - Google Analytics