当前位置:网站首页>SQLite use
SQLite use
2022-06-30 02:43:00 【Rookie nest】
One 、 summary
SQLite You only need to use a single db File can , No need to set up database services . It's very easy to use , Applicable to small single project .
Novice tutorial -SQLite course
https://www.runoob.com/sqlite/sqlite-tutorial.html
Two 、 Use
Use Navicat
You can create a new one directly SQLite
database .
3、 ... and 、 Integrate SpringBoot
1、 Project case
(1)application.yml
spring:
datasource:
driver-class-name: org.sqlite.JDBC
# route :db/mydb.bd
#url: jdbc:sqlite:db/mydb.db
# route :src/main/resources/db/mydb.db
#url: jdbc:sqlite::resource:db/mydb.db
url: jdbc:sqlite:D:/Program Files/sqlite3/mydb.db
username:
password:
mybatis:
mapper-locations:
- classpath:mapper/*.xml
(2)pom.xml
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
(3)student.xml
src/main/resources/mapper/student.xml
<?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="student">
<resultMap id="BaseResultMap" type="java.util.HashMap"></resultMap>
<parameterMap id="BaseParameterMap" type="java.util.HashMap"></parameterMap>
<select id="findStudent" resultMap="BaseResultMap" parameterMap="BaseParameterMap">
select
"id",
"name"
from
student
where
id = #{id}
</select>
</mapper>
(4) Test code
src/test/java/com/scy/sqlite/SqliteApplicationTests.java
package com.scy.sqlite;
import org.apache.ibatis.session.SqlSession;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SpringBootTest
class SqliteApplicationTests {
@Resource
SqlSession sqlSession;
@Test
void contextLoads() {
Map map = new HashMap();
map.put("id", "2");
List<Object> studentList = sqlSession.selectList("student.findStudent", map);
System.out.println(studentList);
}
}
边栏推荐
- Global and Chinese market for defense network security 2022-2028: Research Report on technology, participants, trends, market size and share
- Call collections Sort() method, compare two person objects (by age ratio first, and by name ratio for the same age), and pass lambda expression as a parameter.
- What about punctuation in the first column of unity text
- 多卡服务器使用
- Cmake tutorial series -05- options and variables
- Lua Basics
- Sitelock nine FAQs
- 002 color classification
- Xunwei NXP itop-imx6 development platform
- LeetCode 3. 无重复字符的最长子串
猜你喜欢
FDA邮件安全解决方案
三层交换机和二层交换机区别是什么
Unity TimeLine 数据绑定
LeetCode 3. 无重复字符的最长子串
What are the requirements for NPDP product manager international certification examination?
公司电脑强制休眠的3种解决方案
Shenzhen CPDA Data Analyst Certification in July 2022
[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation
怎么使用Vant实现数据分页和下拉加载
Time complexity analysis
随机推荐
threejs 镜子案例Reflector 创建镜子+房子搭建+小球移动
Linear algebra Chapter 4 Summary of knowledge points of linear equations (Jeff's self perception)
FDA邮件安全解决方案
Jupyter notebook显示k线图集合
主流CA吊销俄罗斯数字证书启示:升级国密算法SSL证书,助力我国网络安全自主可控
What are the requirements for NPDP product manager international certification examination?
SSL证书七大常见错误及解决方法
Summary of knowledge points about eigenvalues and eigenvectors of matrices in Chapter 5 of Linear Algebra (Jeff's self perception)
Five cheapest wildcard SSL certificate brands
How to use SMS to deliver service information to customers? The guide is here!
Bucket sort
Heavy attack -- ue5's open source digital twin solution
VScode如何Debug(调试)进入标准库文件/第三方包源码
Intel-Hex , Motorola S-Record 格式详细解析
C language pivot_ Invalid argument error resolution for root
JS advanced -h5 new features
SQLite使用
HTA入门基础教程 | VBS脚本的GUI界面 HTA简明教程 ,附带完整历程及界面美化
重看《Redis设计与实现》后记录几个要点
oracle怎么设置密码复杂度及超时退出的功能