• Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'stuNo'


    1、错误描述

    ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'stuNo'
    ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'deviceVol'
    	at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:95)
    	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
    	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
    	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
    	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364)
    	at com.sun.proxy.$Proxy18.selectList(Unknown Source)
    	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
    	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
    	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
    Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'stuNo'
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    	at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
    	at com.mysql.jdbc.Util.getInstance(Util.java:360)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:978)
    	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)
    	... 98 more

    2、错误原因

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
    	"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="PorderMapper">
      <select id="stulistPage" parameterType="page" resultType="list">
    		SELECT
    			s.stu_id stuId,
                                                s.stu_no stuNo,
                                                s.stu_name stuName,
                                                s.stu_age stuAge,
                                                s.stu_sex stuSex,
                                                s.stu_addr stuAddr,
                                                s.stu_no stuNo
    		FROM
    		          t_student s
    		
    	</select>
    	
    </mapper>
          查询SQL语句中,查询结果有两个stuNo

    3、解决办法

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
    	"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="PorderMapper">
      <select id="stulistPage" parameterType="page" resultType="list">
    		SELECT
    			s.stu_id stuId,
                                                s.stu_no stuNo,
                                                s.stu_name stuName,
                                                s.stu_age stuAge,
                                                s.stu_sex stuSex,
                                                s.stu_addr stuAddr
    		FROM
    		          t_student s
    		
    	</select>
    	
    </mapper>


  • 相关阅读:
    圣杯局部和双飞翼布局
    解决css英文换行问题
    存在即合理--字体样式大全
    存在即合理---个别软件下载
    sublime Text3常见插件汇总
    省略的方法
    JS数组方法与python列表方法的比较
    vue中数据改变,强制视图更新,视图不更新的原因和解决办法
    Vue通信
    路由的缓存
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313965.html
Copyright © 2020-2023  润新知