当前位置:网站首页>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);
}
}
边栏推荐
- 迅為恩智浦iTOP-IMX6開發平臺
- 身份证号的严谨判断精确到队后一位
- 迅为恩智浦iTOP-IMX6开发平台
- Unity timeline data binding
- A quick look at the statistical data of 23 major cyber crimes from 2021 to 2022
- 怎么利用Redis实现点赞功能
- 【干货分享】最新WHQL徽标认证申请流程
- Playful palette: an interactive parametric color mixer for artists
- VScode如何Debug(调试)进入标准库文件/第三方包源码
- 主流CA吊销俄罗斯数字证书启示:升级国密算法SSL证书,助力我国网络安全自主可控
猜你喜欢

SQL injection -day17

Raki's notes on reading paper: neighborhood matching network for entity alignment

What is the difference between a layer 3 switch and a layer 2 switch

主流CA吊销俄罗斯数字证书启示:升级国密算法SSL证书,助力我国网络安全自主可控

Enlightenment from the revocation of Russian digital certificate by mainstream CA: upgrade the SSL certificate of state secret algorithm to help China's network security to be autonomous and controlla

What is an X.509 certificate? 10. 509 certificate working principle and application?

Jupyter notebook显示k线图集合

Steam elements hidden in science and Technology Education

2. < tag dynamic programming and 0-1 knapsack problem > lt.416 Split equal sum subset + lt.1049 Weight of the last stone II

Créer des compétences exquises dans l'éducation des créateurs
随机推荐
LeetCode 3. 无重复字符的最长子串
模板参数包和函数参数包
Linear algebra Chapter 3 summary of vector and vector space knowledge points (Jeff's self perception)
[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation
JS advanced -es6 syntax
Global and Chinese market for defense network security 2022-2028: Research Report on technology, participants, trends, market size and share
重磅来袭--UE5的开源数字孪生解决方案
Unity TimeLine 数据绑定
Xunwei enzhipu ITop - imx6 Development Platform
Time complexity analysis
身份证号的严谨判断精确到队后一位
Multi card server usage
SSL证书格式转化的两种方法
Enlightenment from the revocation of Russian digital certificate by mainstream CA: upgrade the SSL certificate of state secret algorithm to help China's network security to be autonomous and controlla
什么是X.509证书?X.509证书工作原理及应用?
Unity timeline data binding
Jupyter notebook显示k线图集合
Global and Chinese markets of liquid optical waveguides 2022-2028: Research Report on technology, participants, trends, market size and share
Pytorch学习(二)
Global and Chinese markets for light cargo conveyors 2022-2028: Research Report on technology, participants, trends, market size and share