当前位置: 首页 > news >正文

MySQL数据库(数据库连接池)

文章目录

    • 1.批处理应用
        • 1.基本介绍
        • 2.批处理演示
          • 1.创建测试表
          • 2.修改url
          • 3.编写java代码
        • 3.批处理源码分析
    • 2.数据库连接池
        • 1.传统连接弊端分析
        • 2.数据库连接池基本介绍
          • 1.概念介绍
          • 2.数据库连接池示意图
          • 3.数据库连接池种类
    • 3.C3P0连接池
        • 1.环境配置
          • 1.导入jar包
          • 2.将整个lib添加到项目中
          • 3.配置代码提示
        • 2.C3P0方式一(java程序)
        • 3.C3P0方式二(配置文件)
          • 1.环境配置
            • 1.将c3p0-config.xml配置文件复制到src目录下
            • 2.修改配置文件的参数
          • 2.编写java代码
    • 4.德鲁伊连接池
        • 1.环境配置
          • 1.导入jar包
          • 2.将配置文件复制到src目录下,名字任意
          • 3.修改配置文件的参数
        • 2.编写java代码
    • 5.德鲁伊工具类
        • 1.编写代码
        • 2.测试使用
    • 6.Apache——DBUtils
        • 1.引出
        • 2.基本介绍
        • 3.Apache——DBUtils查询
          • 1.添加依赖
          • 2.编写java代码
            • 1.Actor.java(封装每一行的bean)
            • 2.查询多条记录
          • 3.查询单条记录
          • 4.查询单行单列记录
        • 4.DML操作
    • 7.BasicDao
        • 1.引出
        • 2.BasicDao分析
        • 3.代码实现
          • 1.文件目录
          • 2.BasicDao
          • 3.ActorDao
          • 4.Actor
          • 5.TestDao
          • 6.JDBCUtilsByDruid
          • 7.druid.properties

1.批处理应用

1.基本介绍

image-20240118195806605

image-20240118203024400

2.批处理演示

image-20240118203433909

1.创建测试表
-- 创建的测试表
CREATE TABLE admin2(id INT PRIMARY key auto_increment,username VARCHAR(32) NOT NULL,PASSWORD VARCHAR(32) NOT NULL
)
-- 查看表数据
SELECT * FROM admin2 
-- 查看行数
SELECT count(*) FROM admin2
2.修改url

image-20240118204517836

?rewriteBatchedStatements=true //添加这行代码
3.编写java代码
package jdbc_;import org.junit.jupiter.api.Test;
import utils.JDBCUtils;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;/*** @author 孙显圣* @version 1.0*/
public class Batch_ {@Testpublic void testDML() {//建立连接Connection connection = JDBCUtils.getConnection();//编写sql语句进行插入String sql = "insert into admin2 values (null, ?, ?)";PreparedStatement preparedStatement = null;try {preparedStatement = connection.prepareStatement(sql);//循环进行预处理,并添加到处理包中for (int i = 0; i < 5000; i++) {preparedStatement.setString(1, "Tom");preparedStatement.setString(2, "666666");//1.添加到处理包中,先不执行preparedStatement.addBatch();if ((i + 1) % 1000 == 0) {//2.每执行1000次则执行一次preparedStatement.executeBatch();//3.执行之后清空处理包中的sql语句preparedStatement.clearBatch();}}} catch (SQLException e) {throw new RuntimeException(e);} finally {//关闭资源JDBCUtils.close(null, preparedStatement, connection);}}
}
3.批处理源码分析

image-20240118205608298

image-20240118205232540

2.数据库连接池

1.传统连接弊端分析

image-20240119091642286

image-20240119091627707

2.数据库连接池基本介绍
1.概念介绍

image-20240119091910403

2.数据库连接池示意图

image-20240119092246324

3.数据库连接池种类

image-20240119092345612

3.C3P0连接池

1.环境配置
1.导入jar包

image-20240119094059495

2.将整个lib添加到项目中

image-20240119094146794

3.配置代码提示

image-20240119094217187

2.C3P0方式一(java程序)
    @Testpublic void testC3P01() throws Exception  {//1.创建一个数据源对象,可以理解为这个数据源对象就是那个连接池ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();//2.读取配置文件,获取url,user,password,driverProperties properties = new Properties();properties.load(new FileInputStream("src\\mysql.properties"));String url = properties.getProperty("url");String user = properties.getProperty("user");String password = properties.getProperty("password");String driver = properties.getProperty("driver");//3.给数据源设置相关参数comboPooledDataSource.setJdbcUrl(url);comboPooledDataSource.setUser(user);comboPooledDataSource.setPassword(password);comboPooledDataSource.setDriverClass(driver);//4.设置初始化参数comboPooledDataSource.setInitialPoolSize(10); //初始化连接数comboPooledDataSource.setMaxPoolSize(50); //最大连接数//5.获取连接Connection connection = comboPooledDataSource.getConnection();System.out.println("连接OK");//6.关闭连接connection.close();}
3.C3P0方式二(配置文件)
1.环境配置
1.将c3p0-config.xml配置文件复制到src目录下
<c3p0-config><!-- 数据源名称,可以随意--><named-config name="hello"><!-- 驱动类 --><property name="driverClass">com.mysql.cj.jdbc.Driver</property><!-- url--><property name="jdbcUrl">jdbc:mysql://localhost:3306/hsp_db02</property><!-- 用户名 --><property name="user">root</property><!-- 密码 --><property name="password">root</property><!-- 每次增长的连接数--><property name="acquireIncrement">5</property><!-- 初始的连接数 --><property name="initialPoolSize">10</property><!-- 最小连接数 --><property name="minPoolSize">5</property><!-- 最大连接数 --><property name="maxPoolSize">50</property><!-- 可连接的最多的命令对象数 --><property name="maxStatements">5</property><!-- 每个连接对象可连接的最多的命令对象数 --><property name="maxStatementsPerConnection">2</property></named-config>
</c3p0-config>
2.修改配置文件的参数

image-20240119100430525

2.编写java代码
    @Testpublic void testC3P02() throws Exception {//1.创建与配置文件名称相同的数据源ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource("hello"); //注意:这里的hello是配置文件中的名字//2.获取连接Connection connection = comboPooledDataSource.getConnection();System.out.println("连接OK");//3.关闭连接connection.close();}

4.德鲁伊连接池

1.环境配置
1.导入jar包

image-20240119101351299

2.将配置文件复制到src目录下,名字任意

image-20240119101549362

#key=value
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/girls?rewriteBatchedStatements=true
#url=jdbc:mysql://localhost:3306/girls
username=root
password=root
#initial connection Size
initialSize=10
#min idle connecton size
minIdle=5
#max active connection size
maxActive=50
#max wait time (5000 mil seconds)
maxWait=5000
3.修改配置文件的参数

image-20240119102116306

2.编写java代码
package datasource;import com.alibaba.druid.pool.DruidDataSourceFactory;import javax.sql.DataSource;
import java.io.FileInputStream;
import java.sql.Connection;
import java.util.Properties;/*** @author 孙显圣* @version 1.0*/
public class Druid_ {public static void main(String[] args) throws Exception {//1.读取配置文件Properties properties = new Properties();properties.load(new FileInputStream("src\\druid.properties"));//2.创建数据源对象(就是连接池),将配置文件传进去DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);//3.获取连接Connection connection = dataSource.getConnection();System.out.println("连接OK");//4.关闭连接connection.close();}
}

5.德鲁伊工具类

1.编写代码
package utils;import com.alibaba.druid.pool.DruidDataSourceFactory;import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;/*** @author 孙显圣* @version 1.0*/
public class JDBCUtilsByDruid {//静态数据源引用(jdbc的接口)private static DataSource dataSource;//静态代码块,在类加载时为数据源引用赋值static {//1.读取配置文件Properties properties = new Properties();try {properties.load(new FileInputStream("src\\druid.properties"));} catch (IOException e) {throw new RuntimeException(e);}//2.使用配置文件,创建德鲁伊数据源对象try {dataSource = DruidDataSourceFactory.createDataSource(properties);} catch (Exception e) {throw new RuntimeException(e);}}//编写getConnection方法public static Connection getConnection() {try {return dataSource.getConnection();} catch (SQLException e) {throw new RuntimeException(e);}}//把Connection对象放回连接池public static void close(ResultSet resultSet, Statement statement, Connection connection) {try {if (resultSet != null) {resultSet.close();}if (statement != null) {statement.close();}if (connection != null) {connection.close();}} catch (SQLException e) {throw new RuntimeException(e);}}}
2.测试使用
package datasource;import org.junit.jupiter.api.Test;
import utils.JDBCUtilsByDruid;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;/*** @author 孙显圣* @version 1.0*/
public class DruidUtils_Use {@Testpublic void testSelect() {//建立连接Connection connection = JDBCUtilsByDruid.getConnection();//编写sql语句进行查询String sql = "select name, phone from actor where id = ?";PreparedStatement preparedStatement = null;ResultSet resultSet = null;try {//进行预处理preparedStatement = connection.prepareStatement(sql);preparedStatement.setInt(1, 8);//执行查询resultSet = preparedStatement.executeQuery();while (resultSet.next()) {String string = resultSet.getString("name");String string1 = resultSet.getString("phone");System.out.println(string + " " + string1);}} catch (SQLException e) {throw new RuntimeException(e);} finally {//关闭资源JDBCUtilsByDruid.close(resultSet, preparedStatement, connection);}}}

6.Apache——DBUtils

1.引出

image-20240119133851789

2.基本介绍

image-20240119134845277

3.Apache——DBUtils查询

image-20240119135310282

1.添加依赖

image-20240119135911819

2.编写java代码
1.Actor.java(封装每一行的bean)
package datasource;import java.sql.Timestamp;/*** @author 孙显圣* @version 1.0* 这是一个bean,用来封装actor表的每一行数据*/
public class Actor {private Integer id; //注意要使用包装类private String name;private String sex;private Timestamp borndate; //mysql8只能用这个类型来接受datetimeprivate String phone;public Actor() { //一定要给一个无参构造器[反射需要]}public Actor(Integer id, String name, String sex, Timestamp borndate, String phone) {this.id = id;this.name = name;this.sex = sex;this.borndate = borndate;this.phone = phone;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public Timestamp getBorndate() {return borndate;}public void setBorndate(Timestamp borndate) {this.borndate = borndate;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}@Overridepublic String toString() {return "\nActor{" +"id=" + id +", name='" + name + '\'' +", sex='" + sex + '\'' +", borndate=" + borndate +", phone='" + phone + '\'' +'}';}}
2.查询多条记录

new BeanListHandler<>(Actor.class)

package datasource;import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.junit.jupiter.api.Test;
import utils.JDBCUtilsByDruid;import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;/*** @author 孙显圣* @version 1.0*/
public class DBUtils_USE {@Testpublic void testQueryMan() throws SQLException {//1.得到连接Connection connection = JDBCUtilsByDruid.getConnection();//2.创建QueryRunnerQueryRunner queryRunner = new QueryRunner();//3.编写sqlString sql = "select borndate from actor where id >= ?";//4.调用方法,返回ArrayList结果集,其中每一个元素都是表的一行,封装到了bean中List<Actor> query = queryRunner.query(connection, sql, new BeanListHandler<>(Actor.class), 1); //1就是给里面的问号赋值//5.获取每一行的beanfor (Actor actor : query) {System.out.println(actor);}//6.关闭连接,他会自动关闭resultset和preparedStatementJDBCUtilsByDruid.close(null, null, connection);}}
3.查询单条记录

new BeanHandler<>(Actor.class)

    @Testpublic void testQuerySingle() {//1.获取连接Connection connection = JDBCUtilsByDruid.getConnection();//2.创建queryRunnerQueryRunner queryRunner = new QueryRunner();//3.编写sqlString sql = "select * from actor where id = ?";//4.调用查询方法Actor query = null;try {query = queryRunner.query(connection, sql, new BeanHandler<>(Actor.class), 8);} catch (SQLException e) {throw new RuntimeException(e);}System.out.println(query);//5.关闭资源try {connection.close();} catch (SQLException e) {throw new RuntimeException(e);}}
4.查询单行单列记录

new ScalarHandler()

    @Testpublic  void testScalar() {//1.获取连接Connection connection = JDBCUtilsByDruid.getConnection();//2.创建queryRunnerQueryRunner queryRunner = new QueryRunner();//3.编写sqlString sql = "select name from actor where id = ?"; //单行单列//4.查询try {Object query = queryRunner.query(connection, sql, new ScalarHandler(), 8);System.out.println(query);} catch (SQLException e) {throw new RuntimeException(e);}//5.关闭资源try {connection.close();} catch (SQLException e) {throw new RuntimeException(e);}}
4.DML操作
    @Testpublic void testDML() throws SQLException {//1.获取连接Connection connection = JDBCUtilsByDruid.getConnection();//2.创建queryRunnerQueryRunner queryRunner = new QueryRunner();//3.编写sql//增加String sql1 = "insert into actor values(?, ?, ?, ?, ?)";//删除String sql2 = "delete from actor where id = ?";//修改String sql3 = "update actor set phone = ?";//4.执行sqlint update = queryRunner.update(connection, sql1, null, "张三丰", "男", "2005-11-02", "51552");int update1 = queryRunner.update(connection, sql2, 11);int update2 = queryRunner.update(connection, sql3, 123456);//5.关闭资源try {connection.close();} catch (SQLException e) {throw new RuntimeException(e);}}

7.BasicDao

1.引出

image-20240119162157480

image-20240119162211983

2.BasicDao分析

image-20240119162441113

3.代码实现
1.文件目录

image-20240119173803106

2.BasicDao
package BasicDao_;import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import utils.JDBCUtilsByDruid;import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;/*** @author 孙显圣* @version 1.0* 开发BasicDAO , 是其他DAO的父类*/
public class BasicDao<T> { //泛型指定具体类型private QueryRunner qr =  new QueryRunner();//开发通用的dml方法, 针对任意的表public int update(String sql, Object... parameters) {Connection connection = null;try {connection = JDBCUtilsByDruid.getConnection();int update = qr.update(connection, sql, parameters);return  update;} catch (SQLException e) {throw  new RuntimeException(e); //将编译异常->运行异常 ,抛出} finally {JDBCUtilsByDruid.close(null, null, connection);}}//返回多个对象(即查询的结果是多行), 针对任意表/**** @param sql sql 语句,可以有 ?* @param clazz 传入一个类的Class对象 比如 Actor.class* @param parameters 传入 ? 的具体的值,可以是多个* @return 根据Actor.class 返回对应的 ArrayList 集合*/public List<T> queryMulti(String sql, Class<T> clazz, Object... parameters) {Connection connection = null;try {connection = JDBCUtilsByDruid.getConnection();return qr.query(connection, sql, new BeanListHandler<T>(clazz), parameters);} catch (SQLException e) {throw  new RuntimeException(e); //将编译异常->运行异常 ,抛出} finally {JDBCUtilsByDruid.close(null, null, connection);}}//查询单行结果 的通用方法public T querySingle(String sql, Class<T> clazz, Object... parameters) {Connection connection = null;try {connection = JDBCUtilsByDruid.getConnection();return  qr.query(connection, sql, new BeanHandler<T>(clazz), parameters);} catch (SQLException e) {throw  new RuntimeException(e); //将编译异常->运行异常 ,抛出} finally {JDBCUtilsByDruid.close(null, null, connection);}}//查询单行单列的方法,即返回单值的方法public Object queryScalar(String sql, Object... parameters) {Connection connection = null;try {connection = JDBCUtilsByDruid.getConnection();return  qr.query(connection, sql, new ScalarHandler(), parameters);} catch (SQLException e) {throw  new RuntimeException(e); //将编译异常->运行异常 ,抛出} finally {JDBCUtilsByDruid.close(null, null, connection);}}}
3.ActorDao
package BasicDao_.dao;import BasicDao_.domain.Actor;/*** @author 孙显圣* @version 1.0*/
public class ActorDao extends BasicDao<Actor>{//拥有BasicDao所有的方法//根据业务需求可以写上特有的方法
}
4.Actor
package BasicDao_.domain;import java.sql.Timestamp;/*** @author 孙显圣* @version 1.0* 这是一个bean,用来封装actor表的每一行数据*/
public class Actor {private Integer id;private String name;private String sex;private Timestamp borndate; //mysql8只能用这个类型来接受datetimeprivate String phone;public Actor() { //一定要给一个无参构造器[反射需要]}public Actor(Integer id, String name, String sex, Timestamp borndate, String phone) {this.id = id;this.name = name;this.sex = sex;this.borndate = borndate;this.phone = phone;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public Timestamp getBorndate() {return borndate;}public void setBorndate(Timestamp borndate) {this.borndate = borndate;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}@Overridepublic String toString() {return "\nActor{" +"id=" + id +", name='" + name + '\'' +", sex='" + sex + '\'' +", borndate=" + borndate +", phone='" + phone + '\'' +'}';}}
5.TestDao
package BasicDao_.test;import BasicDao_.dao.ActorDao;
import BasicDao_.domain.Actor;import java.util.List;/*** @author 孙显圣* @version 1.0*/
public class TestDao {public static void main(String[] args) {//测试一下ActorDao对actor表的操作ActorDao actorDao = new ActorDao();//1.查询List<Actor> actors = actorDao.queryMulti("select * from actor where id >?", Actor.class, 2);for (Actor actor : actors) {System.out.println(actor);}//2.查询单行记录Actor actor = actorDao.querySingle("select * from actor where id = ?", Actor.class, 4);System.out.println(actor);//3.查询单行单列记录Object o = actorDao.queryScalar("select name from actor where id = ?", 9);System.out.println(o);//4.增加一条记录int update = actorDao.update("insert into actor values(?,?,?,?,?)", null, "王五", "女", "2002-1-9", "5455555");System.out.println(update > 0 ? "成功" : "失败");//5.删除一条记录int update1 = actorDao.update("delete from actor where id > ?", 10);System.out.println(update1 > 0 ? "成功" : "失败");//6.修改一条记录int update2 = actorDao.update("update actor set name = ?", "女");System.out.println(update2 > 0 ? "成功" : "失败");}
}
6.JDBCUtilsByDruid
package BasicDao_.utils;import com.alibaba.druid.pool.DruidDataSourceFactory;import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;/*** @author 孙显圣* @version 1.0*/
public class JDBCUtilsByDruid {//静态数据源引用(jdbc的接口)private static DataSource dataSource;//静态代码块,在类加载时为数据源引用赋值static {//1.读取配置文件Properties properties = new Properties();try {properties.load(new FileInputStream("src\\druid.properties"));} catch (IOException e) {throw new RuntimeException(e);}//2.使用配置文件,创建德鲁伊数据源对象try {dataSource = DruidDataSourceFactory.createDataSource(properties);} catch (Exception e) {throw new RuntimeException(e);}}//编写getConnection方法public static Connection getConnection() {try {return dataSource.getConnection();} catch (SQLException e) {throw new RuntimeException(e);}}//把Connection对象放回连接池public static void close(ResultSet resultSet, Statement statement, Connection connection) {try {if (resultSet != null) {resultSet.close();}if (statement != null) {statement.close();}if (connection != null) {connection.close();}} catch (SQLException e) {throw new RuntimeException(e);}}}
7.druid.properties
#key=value
driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/hsp_db02?rewriteBatchedStatements=true
#url=jdbc:mysql://localhost:3306/girls
username=root
password=root
#initial connection Size
initialSize=10
#min idle connecton size
minIdle=5
#max active connection size
maxActive=50
#max wait time (5000 mil seconds)
maxWait=5000

相关文章:

MySQL数据库(数据库连接池)

文章目录 1.批处理应用1.基本介绍2.批处理演示1.创建测试表2.修改url3.编写java代码 3.批处理源码分析 2.数据库连接池1.传统连接弊端分析2.数据库连接池基本介绍1.概念介绍2.数据库连接池示意图3.数据库连接池种类 3.C3P0连接池1.环境配置1.导入jar包2.将整个lib添加到项目中3…...

【C#】知识点速通

前言&#xff1a; 笔者是跟着哔站课程&#xff08;Trigger&#xff09;学习unity才去学习的C#&#xff0c;并且C语言功底尚存&#xff0c;所以只是简单地跟着课程将unity所用的C#语言的关键部分进行了了解&#xff0c;然后在后期unity学习过程中加以深度学习。如需完善的C#知识…...

FTP协议

FTP协议 客户端向服务器发送文件。 C/S架构。 运行在TCP/IP协议上面。 FTP客户端要和FTP服务端建立两个TCP连接。 控制连接&#xff1a;运行在整个连接过程&#xff0c;传输控制信息。 数据连接&#xff1a;在每次文件传输时才会建立&#xff0c;文件传输完就关闭。 主动模式…...

前后端分离开发【Yapi平台】【Swagger注解自动生成接口文档平台】

前后端分离开发 介绍开发流程Yapi&#xff08;api接口文档编写平台&#xff09;介绍 Swagger使用方式1). 导入knife4j的maven坐标2). 导入knife4j相关配置类3). 设置静态资源映射4). 在LoginCheckFilter中设置不需要处理的请求路径 查看接口文档常用注解注解介绍 当前项目中&am…...

Android的硬件接口HAL-2 HIDL

没写完哈。 不说废话&#xff0c;直接上干活。 1 创建HAL mkdir -p vendor/fanged/hidltest/1.0/defaultvi vendor/fanged/hidltest/1.0/Ilovefanged.hal package vendor.fanged.hardware.hidltest1.0;interface Ilovefanged {add(int32_t a, int32_t b) generates (int32_t…...

pygame--坦克大战(二)

加载敌方坦克 敌方坦克的方向是随机的,使用随机数生成。 初始化敌方坦克。 class EnemyTank(Tank):def __init__(self,left,top,speed):self.images = {U: pygame.image.load(img/enemy1U.gif),D: pygame.image.load(img/enemy1D.gif),L: pygame.image.load(img/enemy1L.gi…...

【C语言】标准输入/输出(printf, scanf, gets, puts, getchar, putchar)

标准文件文件指针设备标准输入stdin键盘标准输出stdout屏幕标准错误stderr您的屏幕 标准输入/输出的函数在标准库stdio.h。 #include <stdio.h> 1、printf 输出 printf &#xff1a;格式化输出&#xff0c;输出到标准输出stdout中。 printf&#xff1a; int print…...

C、C++、C#中.vscode下json文件记录

C launch.json {// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息&#xff0c;请访问: https://go.microsoft.com/fwlink/?linkid830387"version": "0.2.0","configurations": [{"name": &quo…...

2013年认证杯SPSSPRO杯数学建模B题(第二阶段)流行音乐发展简史全过程文档及程序

2013年认证杯SPSSPRO杯数学建模 B题 流行音乐发展简史 原题再现&#xff1a; 随着互联网的发展&#xff0c;流行音乐的主要传播媒介从传统的电台和唱片逐渐过渡到网络下载和网络电台等。网络电台需要根据收听者的已知喜好&#xff0c;自动推荐并播放其它音乐。由于每个人喜好…...

使用ARCore深度API实现点云采集

一、深度API 本小节内容摘自ARCore官方文档。 ARCore 深度API Depth API 可助力实现对象遮挡、提升沉浸感和新颖的互动体验&#xff0c;从而增强 AR 体验的真实感。 在下图中&#xff0c;右侧画面是采用深度API进行遮挡后的效果&#xff0c;与左侧图相比更加真实。 深度值 给…...

软考数据库

目录 分值分布1. 事务管理1.1 事物的基本概念1.2 数据库的并发控制1.2.1 事务调度概念1.2.2 并发操作带来的问题1.2.3 并发控制技术1.2.4 隔离级别&#xff1a; 1.3 数据库的备份和恢复1.3.1 故障种类1.3.2 备份方法1.3.3 日志文件1.3.4 恢复 2. SQL语言发权限收权限视图触发器…...

Echarts 自适应宽高,或指定宽高进行自适应

文章目录 需求分析 需求 有一个按钮实现对Echarts的指定缩放与拉长&#xff0c;形成自适应效果 拉长后效果图 该块元素缩短后效果图 分析 因为我习惯使用 ref 来获取组件的 DOM 元素&#xff0c;然后进行挂载 <div ref"echartsRef" id"myDiv" :sty…...

体验报告:为什么Claude-3是码农和学者的新宠?

在这个充斥着海量信息的新时代&#xff0c;人工智能的飞速发展带来了翻天覆地的变化。特别是在编程、学术探索以及专业文案创作等领域&#xff0c;AI的助力显得格外关键。最近&#xff0c;我有机会尝试了一种革命性的人工智能工具——Claude-3&#xff0c;其表现令我震惊&#…...

接口自动化框架搭建(九):接入钉钉消息通知

1&#xff0c;jenkins安装钉钉插件 2&#xff0c;在钉钉群聊设置机器人 3&#xff0c;jenkins配置钉钉 根据情况选择&#xff1a; 除了这些&#xff0c;其他不用配置&#xff0c;配置完成点击确认 4&#xff0c;项目配置 添加后保存 5&#xff0c;测试下效果 构建完成后&a…...

一、点击视频下载(通过视频url实现);二、点击下载视频按钮,视频以压缩包形式下载(但未实现压缩视频)

一、点击视频下载&#xff08;通过视频url实现&#xff09; <div class"video-list" v-for"(item,index) in videoList" :key"index"><span class"video-title" >{{item.title}}</span><span class"video-…...

B树、B+树、哈夫曼树

目录 1. B树2. B树3. 哈夫曼树 1. B树 特点&#xff1a;一个节点当中可以有多个值&#xff0c;节点内部key 值是有序的&#xff0c;节点内部存储的是key-value类型的数据 磁盘中文件存储用B树。 4阶B树一个节点最多三个key值 5阶B树一个节点最多四个key值 B树有很多的分支&…...

评价指标_Precision(精确率)、Recall(召回率)和Accuracy(准确率)区别和联系

Precision&#xff08;精确率&#xff09;、Recall&#xff08;召回率&#xff09;和Accuracy&#xff08;准确率&#xff09;是机器学习和信息检索领域常用的评价指标&#xff0c;它们用于评估分类器或检索系统的性能&#xff0c;但各自关注的方面略有不同。 Precision&#x…...

【React】React AJAX

在React中使用AJAX&#xff08;Asynchronous JavaScript and XML&#xff09;是一种常见的做法&#xff0c;用于从服务器获取数据并在组件中显示。尽管AJAX的名字中包含了XML&#xff0c;但现在更多地使用JSON&#xff08;JavaScript Object Notation&#xff09;作为数据交换格…...

vue 移动端弹窗带滚动效果 滚动到底的时候弹窗下的页面会跟着滑动

<template><div class"wrap" :style"dynamicStyle"><!--dynamicStyle主要是介个 通过computed设置postion的值 弹窗的时候设置为fixed 关闭弹窗的时候设置为unset--><div class"banner-wrap"><img src"/assets/…...

Linux-3 yum和vim

目录 本节目标&#xff1a; Linux 软件包管理器 yum 什么是软件包 1.yum是什么&#xff1f;软件包&#xff1f; 2.Linux(centos)的生态 3.yum的相关操作 我怎么知道我应该安装什么软件&#xff1f; 4.yum的本地配置 关于 rzsz 查看软件包 Linux编辑器-vim使用 1.v…...

日语AI面试高效通关秘籍:专业解读与青柚面试智能助攻

在如今就业市场竞争日益激烈的背景下&#xff0c;越来越多的求职者将目光投向了日本及中日双语岗位。但是&#xff0c;一场日语面试往往让许多人感到步履维艰。你是否也曾因为面试官抛出的“刁钻问题”而心生畏惧&#xff1f;面对生疏的日语交流环境&#xff0c;即便提前恶补了…...

基于距离变化能量开销动态调整的WSN低功耗拓扑控制开销算法matlab仿真

目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.算法仿真参数 5.算法理论概述 6.参考文献 7.完整程序 1.程序功能描述 通过动态调整节点通信的能量开销&#xff0c;平衡网络负载&#xff0c;延长WSN生命周期。具体通过建立基于距离的能量消耗模型&am…...

3.3.1_1 检错编码(奇偶校验码)

从这节课开始&#xff0c;我们会探讨数据链路层的差错控制功能&#xff0c;差错控制功能的主要目标是要发现并且解决一个帧内部的位错误&#xff0c;我们需要使用特殊的编码技术去发现帧内部的位错误&#xff0c;当我们发现位错误之后&#xff0c;通常来说有两种解决方案。第一…...

【网络安全产品大调研系列】2. 体验漏洞扫描

前言 2023 年漏洞扫描服务市场规模预计为 3.06&#xff08;十亿美元&#xff09;。漏洞扫描服务市场行业预计将从 2024 年的 3.48&#xff08;十亿美元&#xff09;增长到 2032 年的 9.54&#xff08;十亿美元&#xff09;。预测期内漏洞扫描服务市场 CAGR&#xff08;增长率&…...

剑指offer20_链表中环的入口节点

链表中环的入口节点 给定一个链表&#xff0c;若其中包含环&#xff0c;则输出环的入口节点。 若其中不包含环&#xff0c;则输出null。 数据范围 节点 val 值取值范围 [ 1 , 1000 ] [1,1000] [1,1000]。 节点 val 值各不相同。 链表长度 [ 0 , 500 ] [0,500] [0,500]。 …...

【AI学习】三、AI算法中的向量

在人工智能&#xff08;AI&#xff09;算法中&#xff0c;向量&#xff08;Vector&#xff09;是一种将现实世界中的数据&#xff08;如图像、文本、音频等&#xff09;转化为计算机可处理的数值型特征表示的工具。它是连接人类认知&#xff08;如语义、视觉特征&#xff09;与…...

什么?连接服务器也能可视化显示界面?:基于X11 Forwarding + CentOS + MobaXterm实战指南

文章目录 什么是X11?环境准备实战步骤1️⃣ 服务器端配置(CentOS)2️⃣ 客户端配置(MobaXterm)3️⃣ 验证X11 Forwarding4️⃣ 运行自定义GUI程序(Python示例)5️⃣ 成功效果![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/55aefaea8a9f477e86d065227851fe3d.pn…...

Redis数据倾斜问题解决

Redis 数据倾斜问题解析与解决方案 什么是 Redis 数据倾斜 Redis 数据倾斜指的是在 Redis 集群中&#xff0c;部分节点存储的数据量或访问量远高于其他节点&#xff0c;导致这些节点负载过高&#xff0c;影响整体性能。 数据倾斜的主要表现 部分节点内存使用率远高于其他节…...

dify打造数据可视化图表

一、概述 在日常工作和学习中&#xff0c;我们经常需要和数据打交道。无论是分析报告、项目展示&#xff0c;还是简单的数据洞察&#xff0c;一个清晰直观的图表&#xff0c;往往能胜过千言万语。 一款能让数据可视化变得超级简单的 MCP Server&#xff0c;由蚂蚁集团 AntV 团队…...

云原生玩法三问:构建自定义开发环境

云原生玩法三问&#xff1a;构建自定义开发环境 引言 临时运维一个古董项目&#xff0c;无文档&#xff0c;无环境&#xff0c;无交接人&#xff0c;俗称三无。 运行设备的环境老&#xff0c;本地环境版本高&#xff0c;ssh不过去。正好最近对 腾讯出品的云原生 cnb 感兴趣&…...