学习JDBC这一篇就够了
配套资料,免费下载
链接: https://pan.baidu.com/s/1CKiwCbQV4FGg_4YMQoebkg
提取码: 7cn3
复制这段内容后打开百度网盘手机App,操作更方便哦
第一章 概述
JDBC(Java Database Connectivity)是SUN公司提供的一种数据库访问规则、规范,由于数据库种类较多且Java语言使用比较广泛,SUN公司就提供了一种规范,让其它的数据库提供商去实现底层的访问规则,我们的Java程序只要使用SUN公司提供的jdbc驱动就可以连接不同厂商的数据库了
第二章 数据库连接
1、工具类
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class JDBCUtil {
private static String driverClass = "com.mysql.jdbc.Driver";
private static String url = "jdbc:mysql://127.0.0.1:3306/mytest";
private static String user = "root";
private static String password = "root";
static {
try {
Class.forName(driverClass);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static Connection getConnection() {
try {
return DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public static void release(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet) {
closeConnection(connection);
closePreparedStatement(preparedStatement);
closeResultSet(resultSet);
}
public static void release(Connection connection, PreparedStatement preparedStatement) {
closeConnection(connection);
closePreparedStatement(preparedStatement);
}
public static void closeConnection(Connection connection) {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
connection = null;
}
}
}
public static void closePreparedStatement(PreparedStatement preparedStatement) {
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
preparedStatement = null;
}
}
}
public static void closeResultSet(ResultSet resultSet) {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
resultSet = null;
}
}
}
}
2、测试类
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.junit.Test;
public class JDBCTest {
@Test
public void testQuery() {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = JDBCUtil.getConnection();
String sql = "select * from admin";
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
Object id = resultSet.getObject(1);
Object username = resultSet.getObject(2);
Object password = resultSet.getObject(3);
System.out.println(id + ":" + username + ":" + password);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.release(connection, preparedStatement, resultSet);
}
}
@Test
public void testInsert() {
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
connection = JDBCUtil.getConnection();
String sql = "insert into admin values(NULL,'xiaowu','123456')";
preparedStatement = connection.prepareStatement(sql);
int rows = preparedStatement.executeUpdate(sql);
if (rows > 0) {
System.out.println("插入成功");
} else {
System.out.println("插入失败");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.release(connection, preparedStatement);
}
}
@Test
public void testUpdate() {
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
connection = JDBCUtil.getConnection();
String sql = "update admin set username = 'xiaoqi' where id = 5";
preparedStatement = connection.prepareStatement(sql);
int rows = preparedStatement.executeUpdate(sql);
if (rows > 0) {
System.out.println("修改成功");
} else {
System.out.println("修改失败");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.release(connection, preparedStatement);
}
}
@Test
public void testDelete() {
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
connection = JDBCUtil.getConnection();
String sql = "delete from admin where id = 5";
preparedStatement = connection.prepareStatement(sql);
int rows = preparedStatement.executeUpdate(sql);
if (rows > 0) {
System.out.println("删除成功");
} else {
System.out.println("删除失败");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.release(connection, preparedStatement);
}
}
}
第三章 数据库事务
@Test
public void testTransaction() {
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
connection = JDBCUtil.getConnection();
// 前提:关闭事务
connection.setAutoCommit(false);
String sql = "update account set money = money - ? where id = ?";
preparedStatement = connection.prepareStatement(sql);
// 扣钱, 扣ID为 1 的100块钱
preparedStatement.setInt(1, 100);
preparedStatement.setInt(2, 1);
preparedStatement.executeUpdate();
// 模拟异常
int a = 10 / 0;
// 加钱, 给ID为 2 加100块钱
preparedStatement.setInt(1, -100);
preparedStatement.setInt(2, 2);
preparedStatement.executeUpdate();
// 成功:提交事务
connection.commit();
} catch (SQLException e) {
try {
// 失败:回滚事务
connection.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
} finally {
JDBCUtil.release(connection, preparedStatement);
}
}
第四章 数据库连接池
4.1、DBCP
1、基本使用
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.dbcp2.BasicDataSource;
public class DBCPTest {
public static void main(String[] args) throws SQLException {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUsername("root");
dataSource.setPassword("root");
Connection connection = dataSource.getConnection();
String sql = "select * from admin";
PreparedStatement prepareStatement = connection.prepareStatement(sql);
ResultSet resultSet = prepareStatement.executeQuery();
while (resultSet.next()) {
Object id = resultSet.getObject(1);
Object username = resultSet.getObject(2);
Object password = resultSet.getObject(3);
System.out.println(id + ":" + username + ":" + password);
}
resultSet.close();
connection.close();
dataSource.close();
}
}
2、高级使用
dbcp-config.properties
#基本设置
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/mytest
username=root
password=root
#数据库连接池初始化数量
initialSize=10
#数据库连接池中的最大的数据库连接数
maxActive=50
#数据库连接池中的最小的数据库连接数
minIdle=5
DBCPWithConfig.java
import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSourceFactory;
public class DBCPWithConfig {
@SuppressWarnings("static-access")
public static void main(String[] args) throws Exception {
BasicDataSourceFactory dataSourceFactory = new BasicDataSourceFactory();
Properties properties = new Properties();
InputStream is = DBCPWithConfig.class.getClassLoader().getResourceAsStream("dbcp-config.properties");
properties.load(is);
DataSource dataSource = dataSourceFactory.createDataSource(properties);
Connection connection = dataSource.getConnection();
String sql = "select * from admin";
PreparedStatement prepareStatement = connection.prepareStatement(sql);
ResultSet resultSet = prepareStatement.executeQuery();
while (resultSet.next()) {
Object id = resultSet.getObject(1);
Object username = resultSet.getObject(2);
Object password = resultSet.getObject(3);
System.out.println(id + ":" + username + ":" + password);
}
resultSet.close();
connection.close();
}
}
4.2、Druid
1、基本使用
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.alibaba.druid.pool.DruidDataSource;
public class DruidTest {
public static void main(String[] args) throws SQLException {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUsername("root");
dataSource.setPassword("root");
Connection connection = dataSource.getConnection();
String sql = "select * from admin";
PreparedStatement prepareStatement = connection.prepareStatement(sql);
ResultSet resultSet = prepareStatement.executeQuery();
while (resultSet.next()) {
Object id = resultSet.getObject(1);
Object username = resultSet.getObject(2);
Object password = resultSet.getObject(3);
System.out.println(id + ":" + username + ":" + password);
}
resultSet.close();
connection.close();
dataSource.close();
}
}
2、高级使用
druid-config.properties
#基本设置
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/mytest
username=root
password=root
#数据库连接池初始化数量
initialSize=10
#数据库连接池中的最大的数据库连接数
maxActive=50
#数据库连接池中的最小的数据库连接数
minIdle=5
DruidWithConfig.java
import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
import javax.sql.DataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
public class DruidWithConfig {
@SuppressWarnings("static-access")
public static void main(String[] args) throws Exception {
DruidDataSourceFactory dataSourceFactory = new DruidDataSourceFactory();
Properties properties = new Properties();
InputStream is = DruidWithConfig.class.getClassLoader().getResourceAsStream("druid-config.properties");
properties.load(is);
DataSource dataSource = dataSourceFactory.createDataSource(properties);
Connection connection = dataSource.getConnection();
String sql = "select * from admin";
PreparedStatement prepareStatement = connection.prepareStatement(sql);
ResultSet resultSet = prepareStatement.executeQuery();
while (resultSet.next()) {
Object id = resultSet.getObject(1);
Object username = resultSet.getObject(2);
Object password = resultSet.getObject(3);
System.out.println(id + ":" + username + ":" + password);
}
resultSet.close();
connection.close();
}
}
4.3、C3P0
1、基本使用
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class C3P0Test {
public static void main(String[] args) throws SQLException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
Connection connection = dataSource.getConnection();
String sql = "select * from admin";
PreparedStatement prepareStatement = connection.prepareStatement(sql);
ResultSet resultSet = prepareStatement.executeQuery();
while (resultSet.next()) {
Object id = resultSet.getObject(1);
Object username = resultSet.getObject(2);
Object password = resultSet.getObject(3);
System.out.println(id + ":" + username + ":" + password);
}
resultSet.close();
connection.close();
dataSource.close();
}
}
2、高级使用
c3p0-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<default-config>
<!-- 基本设置 -->
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://127.0.0.1/mytest</property>
<property name="user">root</property>
<property name="password">root</property>
<!-- 数据库连接池初始化数量 -->
<property name="initialPoolSize">10</property>
<!-- 数据库连接池中的最大的数据库连接数 -->
<property name="maxPoolSize">100</property>
<!-- 数据库连接池中的最小的数据库连接数 -->
<property name="minPoolSize">10</property>
</default-config>
</c3p0-config>
C3P0WithConfig.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class C3P0WithConfig {
public static void main(String[] args) throws SQLException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
Connection connection = dataSource.getConnection();
String sql = "select * from admin";
PreparedStatement prepareStatement = connection.prepareStatement(sql);
ResultSet resultSet = prepareStatement.executeQuery();
while (resultSet.next()) {
Object id = resultSet.getObject(1);
Object username = resultSet.getObject(2);
Object password = resultSet.getObject(3);
System.out.println(id + ":" + username + ":" + password);
}
resultSet.close();
connection.close();
dataSource.close();
}
}
第五章 DButils
1、基本的使用
Admin.java
public class Admin {
private Integer id;
private String username;
private String password;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "Admin [id=" + id + ", username=" + username + ", password=" + password + "]";
}
}
DBUtilsTest.java
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.junit.Test;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class DBUtilsTest {
@Test
public void testQueryOne() {
try {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
QueryRunner queryRunner = new QueryRunner(dataSource);
String sql = "select * from admin where id = ?";
Admin admin = queryRunner.query(sql, new BeanHandler<Admin>(Admin.class), 1);
System.out.println(admin);
dataSource.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void testQueryAll() {
try {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
QueryRunner queryRunner = new QueryRunner(dataSource);
String sql = "select * from admin";
List<Admin> admins = queryRunner.query(sql, new BeanListHandler<Admin>(Admin.class));
for (Admin admin : admins) {
System.out.println(admin);
}
dataSource.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void testInsert() {
try {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
QueryRunner queryRunner = new QueryRunner(dataSource);
String sql = "insert into admin values(NULL,?,?)";
int rows = queryRunner.update(sql, "xiaojiu", "123456");
if (rows > 0) {
System.out.println("插入成功");
} else {
System.out.println("插入失败");
}
dataSource.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void testUpdate() {
try {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
QueryRunner queryRunner = new QueryRunner(dataSource);
String sql = "update admin set username = 'xiaoqi' where id = ?";
int rows = queryRunner.update(sql, 4);
if (rows > 0) {
System.out.println("修改成功");
} else {
System.out.println("修改失败");
}
dataSource.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void testDelete() {
try {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
QueryRunner queryRunner = new QueryRunner(dataSource);
String sql = "delete from admin where id = ?";
int rows = queryRunner.update(sql, 6);
if (rows > 0) {
System.out.println("删除成功");
} else {
System.out.println("删除失败");
}
dataSource.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
注意问题:
BeanHandler,查询到的单个数据封装成一个对象
BeanListHandler,查询到的多个数据封装成一个List<对象>
ArrayHandler,查询到的单个数据封装成一个数组
ArrayListHandler,查询到的多个数据封装成一个集合,集合里面的元素是数组
MapHandler,查询到的单个数据封装成一个map
MapListHandler,查询到的多个数据封装成一个集合,集合里面的元素是Map
ColumnListHandler
KeyedHandler
ScalarHandler
2、自定义实现
ResultSetHandler.java
import java.sql.ResultSet;
import java.sql.SQLException;
public interface ResultSetHandler<T> {
/**
* 定义数据封装的规则
*
* @param <T>
* @param rs
*/
T handle(ResultSet rs) throws SQLException;
}
MyQueryRunner.java
import java.sql.Connection;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
public class MyQueryRunner {
private DataSource dataSource = null;
public MyQueryRunner() {
super();
}
public MyQueryRunner(DataSource dataSource) {
super();
this.dataSource = dataSource;
}
public <T> T query(String sql, ResultSetHandler<T> handler, Object... args) {
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
connection = dataSource.getConnection();
preparedStatement = connection.prepareStatement(sql);
ParameterMetaData parameterMetaData = preparedStatement.getParameterMetaData();
for (int i = 0; i < parameterMetaData.getParameterCount(); i++) {
preparedStatement.setObject(i + 1, args[i]);
}
ResultSet resultSet = preparedStatement.executeQuery();
return (T) handler.handle(resultSet);
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.release(connection, preparedStatement);
}
return null;
}
public int update(String sql, Object... args) {
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
connection = dataSource.getConnection();
preparedStatement = connection.prepareStatement(sql);
ParameterMetaData parameterMetaData = preparedStatement.getParameterMetaData();
for (int i = 0; i < parameterMetaData.getParameterCount(); i++) {
preparedStatement.setObject(i + 1, args[i]);
}
return preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.release(connection, preparedStatement);
}
return 0;
}
}
Admin.java
public class Admin {
private Integer id;
private String username;
private String password;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "Admin [id=" + id + ", username=" + username + ", password=" + password + "]";
}
}
MyQueryRunnerTest.java
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class MyQueryRunnerTest {
@Test
public void testQueryOne() {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
MyQueryRunner queryRunner = new MyQueryRunner(dataSource);
String sql = "select * from admin where id = ?";
Admin admin = queryRunner.query(sql, new ResultSetHandler<Admin>() {
@Override
public Admin handle(ResultSet rs) throws SQLException {
while (rs.next()) {
Admin admin = new Admin();
int id = rs.getInt("id");
String username = rs.getString("username");
String password = rs.getString("password");
admin.setId(id);
admin.setUsername(username);
admin.setPassword(password);
return admin;
}
return null;
}
}, 1);
System.out.println(admin);
dataSource.close();
}
@Test
public void testQueryAll() {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
MyQueryRunner queryRunner = new MyQueryRunner(dataSource);
String sql = "select * from admin";
List<Admin> admins = queryRunner.query(sql, new ResultSetHandler<List<Admin>>() {
@Override
public List<Admin> handle(ResultSet rs) throws SQLException {
List<Admin> admins = new ArrayList<Admin>();
while (rs.next()) {
Admin admin = new Admin();
int id = rs.getInt("id");
String username = rs.getString("username");
String password = rs.getString("password");
admin.setId(id);
admin.setUsername(username);
admin.setPassword(password);
admins.add(admin);
}
return admins;
}
});
for (Admin admin : admins) {
System.out.println(admin);
}
dataSource.close();
}
@Test
public void testInsert() {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
MyQueryRunner queryRunner = new MyQueryRunner(dataSource);
String sql = "insert into admin values(NULL,?,?)";
int rows = queryRunner.update(sql, "xiaoqiang", "123456");
if (rows > 0) {
System.out.println("插入成功");
} else {
System.out.println("插入失败");
}
dataSource.close();
}
@Test
public void testUpdate() {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
MyQueryRunner queryRunner = new MyQueryRunner(dataSource);
String sql = "update admin set username = 'mingming' where id = ?";
int rows = queryRunner.update(sql, 4);
if (rows > 0) {
System.out.println("修改成功");
} else {
System.out.println("修改失败");
}
dataSource.close();
}
@Test
public void testDelete() {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mytest");
dataSource.setUser("root");
dataSource.setPassword("root");
MyQueryRunner queryRunner = new MyQueryRunner(dataSource);
String sql = "delete from admin where id = ?";
int rows = queryRunner.update(sql, 7);
if (rows > 0) {
System.out.println("删除成功");
} else {
System.out.println("删除失败");
}
dataSource.close();
}
}
学习JDBC这一篇就够了的更多相关文章
- 学习Hibernate5这一篇就够了
配套资料,免费下载 链接:https://pan.baidu.com/s/1i_RXtOyN1e4MMph6V7ZF-g 提取码:8dw6 复制这段内容后打开百度网盘手机App,操作更方便哦 第一章 ...
- 学习go语言一篇就够了(持续更新)
前言:写博客也写了差不多一年了,我更多的时候是记录自己学习的情况,有时也有自己工作上遇到的bug,自己有时候也比较迷茫,不知道怎么去写博文,我也很想别人跟我提提建议,但是有时候觉得写写博客还是很有成就 ...
- 学习git这一篇就够了!!!
git命令操作 本地库操作 初始化本地仓库 初始化命令 git init $ work % cd workspace $ workspace % mkdir WebService //创建文件夹 $ ...
- SpringBoot入门学习看这一篇就够了
1.SpringBoot是什么? SpringBoot是一套基于Spring框架的微服务框架. 2.为什么需要SpringBoot 由于Spring是一个轻量级的企业开发框架,主要的功能就是用于整合和 ...
- 学习MySQL这一篇就够了
MySQL 第一章 数据库概述 1.1.数据库的好处 将数据持久化到本地 提供结构化查询功能 1.2.数据库的常见概念 DB:数据库,存储数据的仓库 DBS:数据库管理系统,又称为数据库软件或者数据库 ...
- Vue学习看这篇就够
Vue -渐进式JavaScript框架 介绍 vue 中文网 vue github Vue.js 是一套构建用户界面(UI)的渐进式JavaScript框架 库和框架的区别 我们所说的前端框架与库的 ...
- [转帖]nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件
nginx学习,看这一篇就够了:下载.安装.使用:正向代理.反向代理.负载均衡.常用命令和配置文件 2019-10-09 15:53:47 冯insist 阅读数 7285 文章标签: nginx学习 ...
- 关于 Docker 镜像的操作,看完这篇就够啦 !(下)
紧接着上篇<关于 Docker 镜像的操作,看完这篇就够啦 !(上)>,奉上下篇 !!! 镜像作为 Docker 三大核心概念中最重要的一个关键词,它有很多操作,是您想学习容器技术不得不掌 ...
- ASP.NET Core WebApi使用Swagger生成api说明文档看这篇就够了
引言 在使用asp.net core 进行api开发完成后,书写api说明文档对于程序员来说想必是件很痛苦的事情吧,但文档又必须写,而且文档的格式如果没有具体要求的话,最终完成的文档则完全取决于开发者 ...
随机推荐
- 从上到下打印二叉树(剑指offer-22)
题目描述 从上往下打印出二叉树的每个节点,同层节点从左至右打印. 题目解析 使用队列来进行层次遍历,本质上就是宽搜. 题目解答 import java.util.*; /** public class ...
- 基于SpringBoot AOP面向切面编程实现Redis分布式锁
基于SpringBoot AOP面向切面编程实现Redis分布式锁 基于SpringBoot AOP面向切面编程实现Redis分布式锁 基于SpringBoot AOP面向切面编程实现Redis分布式 ...
- ES6入门(一)
目录 ES6入门 (一) let 和 const 命令 let 定义 注意事项 块级作用域 不存在变量提升 let的特点就是存在暂时性死区 特殊情况的暂时性死区 之 ES6函数存在默认值情况 不允许重 ...
- .Net Core 2.2升级3.1的避坑指南
写在前面 微软在更新.Net Core版本的时候,动作往往很大,使得每次更新版本的时候都得小心翼翼,坑实在是太多.往往是悄咪咪的移除了某项功能或者组件,或者不在支持XX方法,这就很花时间去找回需要的东 ...
- web 部署专题(九):Nginx 前后端分离中csrf_token 认证的实现
1. 思路 参考:https://stackoverflow.com/questions/20826201/simple-csrf-protection-using-nginx-alone?r=Sea ...
- python 面向对象专题(五):私有成员、类方法、静态方法、属性、isinstance/issubclass
https://www.cnblogs.com/liubing8/p/11325421.html 目录 Python面向对象05 /私有成员.类方法.静态方法.属性.isinstance/issubc ...
- 【Nginx】如何封禁IP和IP段?看完这篇我会了!!
写在前面 Nginx不仅仅只是一款反向代理和负载均衡服务器,它还能提供很多强大的功能,例如:限流.缓存.黑白名单和灰度发布等等.在之前的文章中,我们已经介绍了Nginx提供的这些功能.小伙伴们可以到[ ...
- 双网卡bonding
网卡:计算机与外界局域网的连接是通过主机箱内插入一块网络接口板(或者是在笔记本电脑中插入一块PCMCIA卡).网络接口板又称为通信适配器或网络适配器(adapter)或网络接口卡NIC(Network ...
- 基于.NetCore3.1系列 ——认证授权方案之Swagger加锁
一.前言 在之前的使用Swagger做Api文档中,我们已经使用Swagger进行开发接口文档,以及更加方便的使用.这一转换,让更多的接口可以以通俗易懂的方式展现给开发人员.而在后续的内容中,为了对a ...
- Unity3D Demo项目开发记录
前言 经过一段时间的学习与实际开发,unity3D也勉强算是强行入门了,正所谓好记性不如烂笔头,更何况本人并非专业从事unity3D开发,会一点C#但也并不熟悉,为了避免后期遗忘,因此特意整理了一个D ...