当前位置: 代码迷 >> J2EE >> There is no statement named saveprimaryUBDin this SqlMap.解决方案
  详细解决方案

There is no statement named saveprimaryUBDin this SqlMap.解决方案

热度:455   发布时间:2016-04-17 23:50:50.0
There is no statement named saveprimaryUBDin this SqlMap.
本帖最后由 u013339851 于 2014-07-21 10:28:40 编辑
ApplicationContext ac = new ClassPathXmlApplicationContext("config/spring-mvc.xml");
SqlMapClientTemplate smct = (SqlMapClientTemplate) ac.getBean("sqlMapClientTemplate");
public class BehaviorDaoImpl{
    public void saveUBD(){
        smct.insert("saveprimaryUBD",subd);
    }
}


spring-mvc配置文件如下:
<?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:task="http://www.springframework.org/schema/task" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation="http://www.springframework.org/schema/mvc 
   http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
           http://www.springframework.org/schema/task
           http://www.springframework.org/schema/task/spring-task-3.0.xsd
           http://www.springframework.org/schema/context    
           http://www.springframework.org/schema/context/spring-context-3.0.xsd"
           default-autowire="byName"
           >
    <!-- spring注解 -->
    <context:annotation-config />
<!-- <context:component-scan base-package="com.founder.ec" /> -->

<!-- Ibatis SqlMap -->
<!-- 连接对象 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" >  
    <property name="configLocation" value="classpath:config/sqlMap.xml" /> 
     <property name="dataSource" ref="dataSource" />
</bean> 
<!-- 连接对象模板 -->
    <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate" >  
        <property name="sqlMapClient" ref="sqlMapClient" />  
    </bean>    
    <!-- 数据源 -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" > 
<property name="driver"> 
<value>com.mysql.jdbc.Driver</value> 
</property> 
<property name="driverUrl"> 
<value>jdbc:mysql://localhost:3306/user_behavior_data</value> 
</property> 
<property name="user"> 
<value>root</value> 
</property> 
<property name="password"> 
<value>zxc123</value> 
</property> 

</bean>  
 
</beans>


sqlMap.xml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
 <!-- 指定映射器路径 -->
 <mappers>
  <mapper resource="sql/ubd.xml" />
 </mappers>
</configuration>


ubd.xml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper 
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" 
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> 
<mapper namespace="com.founder.ec.dao.impl.BehaviorDaoImpl">
   
<insert id="saveprimaryUBD" parameterType="com.founder.ec.entity.PrimaryUBD">
        insert into user_behavior_data.primary_UBD 
        (
        sessionId,
        UUID,
        ip,
        memberId,
        firstPage,
        initTime,
        isNewVisit
        ) 
        values
  相关解决方案