• 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>


  • 相关阅读:
    《梦断代码》阅读笔记01
    linux c netcdf 安装
    Windows CE中的进程和线程
    VC做任务管理器涉及到的函数
    curl_easy_getinfo() -- 从 curl 句柄里获得附加信息
    libcurl programming
    动态内存申请函数选择(realloc、malloc 、alloca、 calloc)
    C++: byte和int的相互转化
    8位灰度图像BMP的保存
    BMP图像的结构及读写和灰度化
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313965.html
Copyright © 2020-2023  润新知