首页 新闻 搜索 专区 学院

Mybatis:ORA-00933: SQL 命令未正确结束

0
[待解决问题]

我感觉应该是拼接if语句的时候出错了,麻烦各位帮忙解答一下,小弟不胜感激!

### Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

### The error may exist in file [E:\scgw\code\code\work\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\EVGlobeServer_SSM\WEB-INF\classes\com\evglobe\mapper\WireDistance.xml]
### The error may involve com.evglobe.mapper.WireDistanceMapper.getWireDistanceInfos-Inline
### The error occurred while setting parameters
### SQL: select t.ev_loopid loopid,t.ev_loopname loopname,t.ev_towername towername,t.ev_ssds ssds, t.ev_powerlevel powerlevel,t.ev_company company,t.ev_altitude altitude, w.ev_distance dis2ground,w.ev_wiredis wiredis from EV_SZJC_TOWERALTITUDE t,EV_COMMON_WIRETOGROUND w where t.ev_loopid=w.ev_loopid and t.ev_order=w.ev_order and t.ev_altitude>=? and t.ev_altitude<? and w.ev_distance>=? and w.ev_distance<? <if test="powerlevel!=null">and t.ev_powerlevel=?</if> <if test="ssds!=null">and t.ev_ssds=?</if> <if test="loopname!=null">and t.ev_loopname=?</if>
### Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束


### Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

### The error may exist in file [E:\scgw\code\code\work\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\EVGlobeServer_SSM\WEB-INF\classes\com\evglobe\mapper\WireDistance.xml]
### The error may involve com.evglobe.mapper.WireDistanceMapper.getWireDistanceInfos-Inline
### The error occurred while setting parameters
### SQL: select t.ev_loopid loopid,t.ev_loopname loopname,t.ev_towername towername,t.ev_ssds ssds, t.ev_powerlevel powerlevel,t.ev_company company,t.ev_altitude altitude, w.ev_distance dis2ground,w.ev_wiredis wiredis from EV_SZJC_TOWERALTITUDE t,EV_COMMON_WIRETOGROUND w where t.ev_loopid=w.ev_loopid and t.ev_order=w.ev_order and t.ev_altitude>=? and t.ev_altitude<? and w.ev_distance>=? and w.ev_distance<? <if test="powerlevel!=null">and t.ev_powerlevel=?</if> <if test="ssds!=null">and t.ev_ssds=?</if> <if test="loopname!=null">and t.ev_loopname=?</if>
### Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

问题补充:

xml中是这样写的:

<![CDATA[
select t.ev_loopid loopid,t.ev_loopname loopname,t.ev_towername towername,t.ev_ssds ssds,
t.ev_powerlevel powerlevel,t.ev_company company,t.ev_altitude altitude,
w.ev_distance dis2ground,w.ev_wiredis wiredis
from EV_SZJC_TOWERALTITUDE t,EV_COMMON_WIRETOGROUND w
where t.ev_loopid=w.ev_loopid and t.ev_order=w.ev_order
and t.ev_altitude>=#{minalt} and t.ev_altitude<#{maxalt}
and w.ev_distance>=#{mindis2ground} and w.ev_distance<#{maxdis2ground}
and t.ev_powerlevel=#{powerlevel}
<if test="powerlevel!=null">and t.ev_powerlevel=#{powerlevel,jdbcType=VARCHAR}</if>
<if test="ssds!=null">and t.ev_ssds=#{ssds,jdbcType=VARCHAR}</if>
<if test="loopname!=null">and t.ev_loopname=#{loopname,jdbcType=VARCHAR}</if>

]]>

MaxFish的主页 MaxFish | 初学一级 | 园豆:165
提问于:2017-09-08 10:10
< >
分享
所有回答(2)
0

<if test="powerlevel!=null">and t.ev_powerlevel=?</if> <if test="ssds!=null">and t.ev_ssds=?</if> <if test="loopname!=null">and t.ev_loopname=?</if>  你这段代码是不是在拼接sql的时候写错了。。。

队长给我球。 | 园豆:352 (菜鸟二级) | 2017-09-08 11:00
0

切换数据源时没有调用切换代码!!!

MaxFish | 园豆:165 (初学一级) | 2017-10-15 09:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册