springboot 连接 Access数据库

1、pom中导入maven包

<dependency>
<groupId>net.sf.ucanaccess</groupId>
<artifactId>ucanaccess</artifactId>
<version>4.0.4</version>
</dependency>

2、application.yml配置连接

spring:
datasource:
driver-class-name: net.ucanaccess.jdbc.UcanaccessDriver
url: jdbc:ucanaccess://D:/xxx/xxx/xxx/Database1.accdb;openExclusive=false;ignoreCase

3、创建mapper 写sql

<?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="com.orisdom.handle.mapper.HandleMapper">
<resultMap id="BaseMap" type="com.orisdom.handle.entity.HandleEntity">
<result column="id" property="id"/>
<result column="weight" property="weight" />
<result column="user_name" property="userName" />
</resultMap>
<select id="getHandleData" resultMap="BaseMap">
SELECT id,user_name ,weight FROM [重量] where ID >#{id}
</select>
</mapper>

数据库大致模式(这里只是为了记录配置连接,创建mapper接口,entity等就不需要在贴出来了)

原文地址:https://www.cnblogs.com/xiaokangk/p/13208478.html