码迷,mamicode.com
首页 > 数据库 > 详细

spring+mybatis连接access数据库

时间:2016-03-05 14:40:06      阅读:911      评论:0      收藏:0      [点我收藏+]

标签:

1.所需jar包:

spring

mybatis

common-dhcp (版本1.4以上,1.4以下无法支持connectionProperties属性)

 

注意事项:

连接access数据库前请关闭log4j, log4j的控制台sql日志输出会导致 not data SQLException

 

2.pom.xml

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>3.1.1.RELEASE</version>
    </dependency>
    
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>3.1.1.RELEASE</version>
    </dependency>
    
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>3.1.1.RELEASE</version>
    </dependency>
    
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>3.1.1.RELEASE</version>
    </dependency>
    
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.2.0</version>
    </dependency>
    
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.2.2</version>
    </dependency>      

3.spring-context.xml

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
        <property name="driverClassName" value="sun.jdbc.odbc.JdbcOdbcDriver" />  
        <property name="url" value="jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:/workspace/eclipse/attend/data/attend.mdb" />
        <property name="connectionProperties">  
            <value>charSet=gbk</value>
        </property>  
</bean>
connectionProperties属性重要,不加上会导致中文乱码

spring+mybatis连接access数据库

标签:

原文地址:http://www.cnblogs.com/sz-zzm/p/5244757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!