mybatis中sql问题求解决

问题描述

mybatis中sql问题求解决

在mysql客户端中执行下面语句

 select
            sk.seckill_id,
            sk.user_phone,
            sk.create_time,
            sk.state,
            s.seckill_id "seckill.seckill_id",
            s.name "seckill.name",
            s.number "seckill.number",
            s.start_time "seckill.start_time",
            s.end_time "seckill.end_time",
            s.create_time "seckill.create_time"
        from success_killed sk
        inner join seckill s on sk.seckill_id = s.seckill_id
where sk.seckill_id=1 and sk.user_phone=13573615842

没有报错,但是配置在mybatis的xml中会出现下面的错误
信息: Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
五月 21, 2016 10:50:17 上午 org.springframework.jdbc.support.SQLErrorCodesFactory
信息: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
五月 21, 2016 10:50:17 上午 org.springframework.context.support.GenericApplicationContext doClose
信息: Closing org.springframework.context.support.GenericApplicationContext@4351aa16: startup date [Sat May 21 10:50:16 CST 2016]; root of context hierarchy

求解释

解决方案

mybatis sql 映射文件问题

解决方案二:

Spring容器配置有錯,發出來看看

解决方案三:

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-4.1.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
            http://www.springframework.org/schema/util
            http://www.springframework.org/schema/util/spring-util-4.1.xsd">
    <!-- 配置整合mybatis过程 -->
    <!-- 1:配置数据库相关参数 -->
    <context:property-placeholder location="classpath:jdbc.properties"/>
    <!-- 配置数据库连接池 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <!-- 配置连接池属性
        不要用username,因为会冲突
        -->
        <property name="driverClass" value="${driver}"/>
        <property name="jdbcUrl" value="${url}"/>
        <property name="user" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <!-- c3p0连接池的私有属性 -->
        <property name="maxPoolSize" value="30"/>
        <property name="minPoolSize" value="10"/>
        <!-- 关闭连接后不自动commit -->
        <property name="autoCommitOnClose" value="false"/>
        <!-- 获取连接超时时间 -->
        <property name="checkoutTimeout" value="1000"/>
        <!-- 当获取连接失败重试次数 -->
        <property name="acquireRetryAttempts" value="2"/>
    </bean>

    <!-- 配置SqlSessionFactoty对象 -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!-- 注入数据库连接池 -->
        <property name="dataSource" ref="dataSource"/>
        <!-- 配置MyBatis全局配置文件:mybatis-config.xml -->
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
        <!-- 扫描entity包,使用别名 -->
        <property name="typeAliasesPackage" value="cn.icodelife.entity"/>
        <!-- 扫描sql配置文件:mapper需要的xml文件 -->
        <property name="mapperLocations" value="classpath:mapper/*.xml"/>
    </bean>

    <!-- 配置扫描dao接口包 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <!-- 注入sqlSessionFactory -->
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
        <!-- 给出扫描dao接口的包 -->
        <property name="basePackage" value="cn.icodelife.dao"/>
    </bean>
</beans>

解决方案四:

数据库里添加的数据库类型不一样,看看那个属性的数据类型不一致

时间: 2024-08-01 19:31:42

mybatis中sql问题求解决的相关文章

select-sql语句in的用法,在mybatis中sql中in是怎么用的

问题描述 sql语句in的用法,在mybatis中sql中in是怎么用的 SELECT a.smid,a.smx,a.smy,a.NAME FROM BusPoint a , BusPointline b WHERE a.StopID = b.BusPointID AND a.smid in (133,132); 在mybatis框架中,上面的sql语句如何编写? 在mybatis框架中,sql中in是怎么用的? 那位大神知道~~~ 解决方案 导读: select * from txt1 sel

sql server-SQL SERVER求解决一个归类的问题

问题描述 SQL SERVER求解决一个归类的问题 id 学生 课程 成绩 1 张三 语文 80 2 张三 数学 70 3 张三 政治 85 4 李四 语文 80 4 李四 数学 75 5 马五 数学 60 6 马五 英语 75 7 马五 政治 80 转换为 姓名 语文 数学 英语 政治 张三 80 70 0 85 李四 80 75 0 0 马五 0 60 75 80 解决方案 http://www.cnblogs.com/luowende2012/archive/2012/07/19/2599

tomcat-Tomcat服务器中url中文传值乱码,急,求解决。。。

问题描述 Tomcat服务器中url中文传值乱码,急,求解决... 上海 在servlet中获取城市,设置了编码为UTF-8,然后跳转带页面, <% String city=(String)session.getAttribute("city"); %> <%=city %>切换城市 不管选择哪个城市,最终显示在网页都是??,求各位大神给出个解决办法.. 解决方案 URL中文乱码服务器端(tomcat)解决方法 解决方案二: java URLEncoder和UR

sql server-SQL server安装出错,求解决方法

问题描述 SQL server安装出错,求解决方法 !图片说明 解决方案 http://jingyan.baidu.com/article/148a192192a3994d71c3b1e7.html 解决方案二: 安装SQL Server 2005出错的解决方法sql server 中关于Order By 在子查询嵌套中的出错的解决方法! 解决方案三: 安装文件的问题 解决方案四: 卸载掉所有的组件,删除所有的文件,注册表等信息重新安装

mybatis的sql语句,求解答

问题描述 mybatis的sql语句,求解答 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 'a where a.store_id= ''' at line 1,一直找不到id这个是其中文件删除语句 You have an error in your SQL syntax; c

详解Java的MyBatis框架中SQL语句映射部分的编写_java

1.resultMapSQL 映射XML 文件是所有sql语句放置的地方.需要定义一个workspace,一般定义为对应的接口类的路径.写好SQL语句映射文件后,需要在MyBAtis配置文件mappers标签中引用,例如: <mappers> <mapper resource="com/liming/manager/data/mappers/UserMapper.xml" /> <mapper resource="com/liming/manag

Mybatis中执行String类型的自己拼写的sql,不执行配置文件中的sql

Mybatis中执行String类型的自己拼写的sql,不执行配置文件中的sql 在自己的dao类中继承SqlSessionDaoSupport类 /** * @author herman.xiong * @since 0.1 * @param <T>实体类 * @param <PK>主键类,必须实现Serializable接口 */ package com.dao; import java.io.Serializable; import org.apache.log4j.Logg

跳转路径-急求解决,jsp页面中循环生成的form表单,action路径错误

问题描述 急求解决,jsp页面中循环生成的form表单,action路径错误 在jsp页面中用循环生成的form表单,为什么action不是想要的呢,代码贴在下面了 reply=(Map)request.getAttribute("REPLY"); while(rsComment.next()) { // 评论编号 String CId = rsComment.getString("CId"); // 评论人 String name=rsComment.getStr

test-《matlab智能算法30个案例》中的第29个案例运行不出图为什么呢?急求解决

问题描述 <matlab智能算法30个案例>中的第29个案例运行不出图为什么呢?急求解决 如题,显示 Error using plot Vectors must be the same lengths. Error in test (line 72) plot(1:length(t_train),t_train,'r-*',1:length(t_train),predict_1,'b:o') 解决方案 出错了当然不会显示.说向量的长度必须相等.错在第72行.最好把你的代码贴出来看看 解决方案二