当前位置:网站首页>SQLite使用
SQLite使用
2022-06-30 02:31:00 【菜鸟小窝】
一、概述
SQLite 只需要使用单个db文件即可,不用建立数据库服务。非常简单易用,适用于小型单体项目。
菜鸟教程-SQLite 教程
https://www.runoob.com/sqlite/sqlite-tutorial.html
二、使用
使用Navicat可以直接新建SQLite数据库。
三、集成 SpringBoot
1、项目案例
(1)application.yml
spring:
datasource:
driver-class-name: org.sqlite.JDBC
# 路径:db/mydb.bd
#url: jdbc:sqlite:db/mydb.db
# 路径: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)测试代码
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);
}
}
边栏推荐
猜你喜欢
![[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation](/img/c3/f9d6399c931a006ca295bb1e3ac427.png)
[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation
![[on] [DSTG] dynamic spatiotemporalgraph revolutionary neural networks for traffic data impact](/img/c3/f9d6399c931a006ca295bb1e3ac427.png)
[on] [DSTG] dynamic spatiotemporalgraph revolutionary neural networks for traffic data impact

有流量,但没有销售?增加网站销量的 6 个步骤

A quick look at the statistical data of 23 major cyber crimes from 2021 to 2022

选择排序

2.8 【 weight of complete binary tree 】

Sitelock nine FAQs

什么是自签名证书?自签名SSL证书的优缺点?

Unity3D UGUI强制刷新Layout(布局)组件

Select sort
随机推荐
代码签名、驱动签名的常见问题解答
NCA: the nine year old has launched a DDoS attack
CA数字证书包含哪些文件?如何查看SSL证书信息?
Implement vs to run only one source file at a time
DHU programming exercise
Global and Chinese markets for wireless security in LTE networks 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets for light cargo conveyors 2022-2028: Research Report on technology, participants, trends, market size and share
What is an X.509 certificate? 10. 509 certificate working principle and application?
Steam elements hidden in science and Technology Education
Pytorch学习(二)
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
DDoS extortion attacks: what you need to know
Traffic, but no sales? 6 steps to increase website sales
FDA mail security solution
A quick look at the statistical data of 23 major cyber crimes from 2021 to 2022
SQL injection -day17
DHU programming exercise
AutoJS代碼能加密嗎?YES,AutoJS加密技巧展示
[on] [DSTG] dynamic spatiotemporalgraph revolutionary neural networks for traffic data impact
Alphassl digital certificate