JDBC学习,从入门到入土

news2024/10/6 4:06:40

JDBC引入

JDBC概念:

JDBC是使用Java语言操作关系型数据库的一套API。全称:(Java DataBase Connectivity)Java数据库连接

JDBC的本质:

官方定义的一套操作所有关系型数据库的规则,即接口

各个数据库厂商去实现这套接口,即提供实现类,这些实现类也叫做驱动, 厂商提供的是相应的数据库驱动jar包。我们可以使用这套接口(JDBC)编程,真正执行的是驱动jar包中的实现类。

JDBC的好处:

各数据库厂商使用相同的接口,Java代码不需要针对不同的数据库分别开发。可随时替换底层数据库,访问数据库的Java代码基本不变。

JDBC的使用步骤

有七步,如代码所示:

package JDBC学习;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class test1 {
    public static void main(String[] args) {
        Connection conn = null;
        Statement sta = null;
        try {
            //1 注册驱动
            Class.forName("com.mysql.cj.jdbc.Driver");

            //2 获取连接
            String url = "jdbc:mysql://127.0.0.1:3306/limingmao";
            String username = "liergou";
            String password = "liergou070509";
            conn = DriverManager.getConnection(url, username, password);

            //3 定义SQL
            String sql_1 = "UPDATE emp1 SET salary = 20000 WHERE `name` = 'Tom'";

            //4 获取执行sql的对象Statement
            sta = conn.createStatement();

            //5 执行sql
            int i = sta.executeUpdate(sql_1);//i为受影响的行数

            //6 处理结果
            System.out.println(i);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            //7 释放资源
            try {
                sta.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}

注:mysql5.0之后可以省略注册驱动一步

JDBC API详解

DiverManager

DiverManager(驱动管理类)作用:

  1. 注册驱动
  2. 获取数据库连接

关于DiverManager中的静态方法static Connection getConnection(String url,String user,String password)

参数:
  1. url:连接路径

  1. user:用户名
  2. password:密码

Connection

Connection(数据库连接对象)作用:

  1. 获取执行SQL的对象
  2. 管理事务

获取执行SQL的对象

  • 普通执行SQL对象

Statement createStatement()

  • 预编译SQL的执行SQL对象:防止SQL注入

PreparedStatement preparedStatement(sql)

  • 执行存储变量的对象

CallableStatement prepareCall(sql)

 事务管理

 可以利用JDBC的三个方法来管理事务:

package JDBC学习;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class test2 {
    public static void main(String[] args) {
        Connection conn = null;
        Statement sta = null;
        try {
            //1 注册驱动
            //Class.forName("com.mysql.cj.jdbc.Driver");

            //2 获取连接
            String url = "jdbc:mysql://127.0.0.1:3306/limingmao";
            String username = "liergou";
            String password = "liergou070509";
            conn = DriverManager.getConnection(url, username, password);

            //3 定义SQL
            String sql_1 = "UPDATE emp1 SET salary = 20000 WHERE `name` = 'Tom'";
            String sql_2 = "UPDATE emp1 SET salary = 20000 WHERE `name` = '丘丘人'";

            //4 获取执行sql的对象Statement
            sta = conn.createStatement();

            //开启事务
            conn.setAutoCommit(false);

            //5 执行sql
            int i = sta.executeUpdate(sql_1);//i为受影响的行数
            int j = sta.executeUpdate(sql_2);//i为受影响的行数
            //6 处理结果
            System.out.println(i);
            System.out.println(j);

            //提交事务
            conn.commit();

        } /*catch (ClassNotFoundException e) {
            e.printStackTrace();
        } */catch (SQLException e) {
            //回滚事务
            try {
                conn.rollback();
            } catch (SQLException ex) {
                e.printStackTrace();
            }
            e.printStackTrace();
        } finally {
            //7 释放资源
            try {
                sta.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}

先设置MySQL不自动提交事务,在try中末尾处加上提交事务的操作。如果出现异常,说明此异常操作的事务不应该提交,要回滚事务。将回滚事务的操作放在catch中,随着和对异常的处理操作一起进行回滚操作

Statement

Statement作用:

执行SQL语句。

执行SQL语句

int executeUpdate(sql):执行DML、DDL语句

返回值:①DML语句影响的行数 ②DDL语句执行后,执行成功也可能返回0

ResultSet executeQuery(sql):执行DQL语句

返回值:ResultSet结果集对象

ResultSet

Result(结果集对象)作用:

封装了DQL查询语句的结果

ResultSet executeQuery(sql):执行DQL语句

返回值:ResultSet结果集对象

获取查询结果

boolean next():①将指针从当前位置移动到下一行 ②判断当前行是否为有效行

返回值:true,有效行,当前行有数据;false,无效行,当前行没有数据。

xxx getXxx(参数):获取数据

xxx:数据类型。如int getInt()、String getString(参数)

参数:int,列的编号,从1开始。String:列的名称。

使用

使用时通常会用上while循环

while(…….next()){

……

…….getXxx(参数);

}

例:查询员工表emp1中的数据并打印。

@Test
void test3() {
    Connection conn = null;
    Statement sta = null;
    ResultSet rs = null;
    try {
        //获取连接(注册驱动已省略)
        String url = "jdbc:mysql:///limingmao";
        String username = "liergou";
        String password = "liergou070509";
        conn = DriverManager.getConnection(url,username,password);
        //定义SQL语句
        String sql_1 = "select * from emp1";
        //获取statement对象
        sta = conn.createStatement();
        //执行sql
        rs = sta.executeQuery(sql_1);
        //处理结果,遍历查询的所有结果
        while(rs.next())
        {
            int id = rs.getInt("id");
            String name = rs.getString(2);
            Date date = rs.getDate(3);
            double salary = rs.getDouble("salary");

            System.out.print(id + "\t");
            System.out.print(name + "\t");
            System.out.print(date + "\t");
            System.out.print(salary + "\t");
            System.out.println();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        //释放资源
        try {
            rs.close();
            sta.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

还可以使用其查询数据做Java代码的处理,例:将员工的sal添加到一个Arraylist中。

@Test
void test4() {
    Connection conn = null;
    Statement sta = null;
    ResultSet rs = null;
    try {
        //获取连接(注册驱动已省略)
        String url = "jdbc:mysql:///limingmao";
        String username = "liergou";
        String password = "liergou070509";
        conn = DriverManager.getConnection(url,username,password);
        //定义SQL语句
        String sql_1 = "select salary from emp1";
        //获取statement对象
        sta = conn.createStatement();
        //执行sql
        rs = sta.executeQuery(sql_1);
        //处理结果,遍历查询的所有结果
        ArrayList<Double> sal = new ArrayList<>();
        while(rs.next())
        {
            double salary = rs.getDouble("salary");
            sal.add(salary);
        }
        Iterator ii = sal.iterator();
        while (ii.hasNext())
        {
            System.out.println(ii.next());
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        //释放资源
        try {
            rs.close();
            sta.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

例:将员工的信息添加到一个Arraylist中。

@Test
void test5() {
    Connection conn = null;
    Statement sta = null;
    ResultSet rs = null;
    try {
        //获取连接(注册驱动已省略)
        String url = "jdbc:mysql:///limingmao";
        String username = "liergou";
        String password = "liergou070509";
        conn = DriverManager.getConnection(url,username,password);
        //定义SQL语句
        String sql_1 = "select * from emp1";
        //获取statement对象
        sta = conn.createStatement();
        //执行sql
        rs = sta.executeQuery(sql_1);
        //处理结果,遍历查询的所有结果
        ArrayList<Employee> employees = new ArrayList<>();
        while(rs.next())
        {
            int id = rs.getInt(1);
            String name = rs.getString("name");
            Date date = rs.getDate(3);
            double salary = rs.getDouble("salary");
            employees.add(new Employee(id,name,date,salary));
        }
        Iterator ii = employees.iterator();
        while (ii.hasNext())
        {
            System.out.println(ii.next());
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        //释放资源
        try {
            rs.close();
            sta.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

PreparedStatement

PreparedStatement作用:

预编译SQL语句并执行:预防SQL注入问题

SQL注入

即利用SQL语句的语法,在填入时,强制查询结果为true。

操作

①获取PrepareStatement对象

//SQL语句中的参数值,使用?占位符替代
String sql = "SELECCT * FROM user WHERE username = ? AND password = ?";

//通过Connection对象获取,并传入相应的SQL语句。
PreparedStatement psta = conn.prepareStatement(sql);

②设置参数值

PreparedStatement对象:setXxx(参数1,参数2):给?赋值

Xxx指的是数据类型,参数1是?的顺序编号,从一开始。参数2是?的具体的值

③执行SQL

使用:executeUpdate()/executeQuery():不需要再传入SQL语句。

例:

@Test
void test7()
{
    Connection conn = null;
    PreparedStatement psta = null;
    ResultSet rs = null;
    try {
        //获取连接
        String url = "jdbc:mysql:///limingmao";
        String username = "liergou";
        String password = "liergou070509";
        conn = DriverManager.getConnection(url,username,password);

        //接收用户输入的用户名和密码
        String uname = "张三";
        String pwd = "1234";
        //定义SQL
        String sql = "SELECT * FROM tb_user WHERE username = ? AND password = ?";
        //获取psta对象
        psta = conn.prepareStatement(sql);
        //设置?的值
        psta.setString(1,uname);
        psta.setString(2,pwd);
        //执行SQL语句
        rs = psta.executeQuery();
        //判断是否成功
        if(rs.next()) {
            System.out.println("登录成功");
        }else {
            System.out.println("登录失败");
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        try {
            //释放资源
            rs.close();
            psta.close();
            conn.close();

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

PreparedStatement原理

  1. 在获取PreparedStatement对象时,将SQL语句发送给MySQL服务器进行检查、编译
  2. 执行时就不用再进行这些步骤了,速度更快
  3. 如果SQL模板一样,则只需要进行一次检查、编译

PreparedStatement好处:

  1. 预编译SQL,性能更高
  2. 防止SQL注入:将敏感字符进行转义

开启预编译功能:

userServerPrepStmts=true:将此参数键值对放到url的参数键值对处。

数据库连接池

简介

数据库连接池是个容器,负责分配、管理数据库连接(Connection)

它允许应用程序重复使用一个现有的数据库连接,而不是再重新建立一个

释放空闲时间超过最大空闲时间的数据库连接来避免因为没有释放数据库连接而引起的数据库连接遗漏

好处:

  • 资源重用
  • 提升系统响应速度
  • 避免数据库连接遗漏

数据库连接池实现

标准接口:DataSource

官方提供的数据库连接池标准接口,由第三方组织实现此接口。

功能:获取连接

Connection getConnection()

常见的数据库连接池:

  • DBCP
  • C3P0
  • Druid

Druid(德鲁伊)

Druid连接池是阿里巴巴开源的数据库连接池项目

功能强大,性能优秀,是Java语言最好的数据库连接池之一

使用步骤以及代码实现如下:

public class test_druid {
    public static void main(String[] args){
        try {
            //加载配置文件
            Properties prop = new Properties();
            prop.load(new FileInputStream("D:\\李明茂\\Java学习\\JDBC\\src\\druid.properties"));
            //获取连接池对象
            DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
            //获取数据库连接Connection
            Connection conn = dataSource.getConnection();
            System.out.println(conn);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

JDBC练习:实现品牌列表的增删查改

要求:使用数据库连接池(德鲁伊),使用预编译防SQL注入的PreparedStatement

题目准备:

数据库准备:

CREATE TABLE tb_brand(
id INT PRIMARY KEY AUTO_INCREMENT,
brand_name VARCHAR(20),-- 品牌名称
company_name VARCHAR(20),-- 企业名称
ordered INT,-- 排序字段
description VARCHAR(100),-- 描述信息
`status` INT-- 状态 0表示禁用,1表示启用
);

INSERT INTO tb_brand(brand_name,company_name,ordered,description,`status`)
VALUES('金坷拉','金坷垃股份有限公司',5,'要种庄稼,必须要有金坷垃',0),
('米哈游','米哈游技术有限公司',100,'技术宅拯救世界',1),
('腾讯','腾讯技术有限公司',50,'下元梦之心',1);

SELECT * FROM tb_brand;

DESC tb_brand;

Java中Brand类的准备:

public class Brand {
private Integer id;
private String brandName;
private String companyName;
private Integer ordered;
private String description;
private Integer status;

    public Brand() {
    }

    public Brand(Integer id, String brandName, String companyName, Integer ordered, String description, Integer status) {
        this.id = id;
        this.brandName = brandName;
        this.companyName = companyName;
        this.ordered = ordered;
        this.description = description;
        this.status = status;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBrandName() {
        return brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public Integer getOrdered() {
        return ordered;
    }

    public void setOrdered(Integer ordered) {
        this.ordered = ordered;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Override
    public String toString() {
        return "Brand{" +
                "id=" + id +
                ", brandName='" + brandName + '\'' +
                ", companyName='" + companyName + '\'' +
                ", ordered=" + ordered +
                ", description='" + description + '\'' +
                ", status=" + status +
                '}';
    }
}

开始练习:

查所有数据:(单元测试方法中实现,下同)

/**
     * 查询所有
     * SQL语句:SELECT * FROM tb_brand;
     * 参数:不需要
     * 结果:List<Brand>
     */
    @Test
    public void testSelectAll(){
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;

        try {
            //加载配置文件
            Properties prop = new Properties();
            prop.load(new FileInputStream("D:\\李明茂\\Java学习\\JDBC\\src\\druid.properties"));
            //获取连接池对象
            DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
            //获取数据库连接Connection
            conn = dataSource.getConnection();

            //定义SQL语句
            String sql = "SELECT * FROM tb_brand";

            //获取PreparedStatement对象
            pstmt = conn.prepareStatement(sql);

            //执行SQL语句
            rs = pstmt.executeQuery();

            //处理结果
            List<Brand> brands = new ArrayList<>();
            while(rs.next())
            {
                brands.add(
                        new Brand(
                                rs.getInt("id"),
                                rs.getString(2),
                                rs.getString(3),
                                rs.getInt(4),
                                rs.getString("description"),
                                rs.getInt(6)
                                 )
                          );
            }
            Iterator ii = brands.iterator();
            while (ii.hasNext())
            {
                System.out.println(ii.next());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                rs.close();
                pstmt.close();
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

增:

/**
     * 添加
     * SQL语句:
     * INSERT INTO tb_brand(brand_name,company_name,ordered,description,`status`) VALUES(?,?,?,?,?);
     * 参数:需要,除了id之外的所有参数,共五个。
     */
    @Test
    public void testAdd()
    {
        Connection conn = null;
        PreparedStatement pstmt = null;
        //假设接受到的添加的信息如下:
        String brandName = "网易";
        String companyName = "网易技术有限公司";
        Integer ordered = 1;
        String description = "下蛋仔派对";
        Integer status = 1;

        try {
            //加载配置文件
            Properties prop = new Properties();
            prop.load(new FileInputStream("D:\\李明茂\\Java学习\\JDBC\\src\\druid.properties"));
            //获取连接池对象
            DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
            //获取数据库连接Connection
            conn = dataSource.getConnection();

            //定义SQL语句
            String sql = "INSERT INTO tb_brand(brand_name,company_name,ordered,description,`status`) VALUES(?,?,?,?,?);";

            //获取PreparedStatement对象
            pstmt = conn.prepareStatement(sql);

            //设置参数
            pstmt.setString(1,brandName);
            pstmt.setString(2,companyName);
            pstmt.setInt(3,ordered);
            pstmt.setString(4,description);
            pstmt.setInt(5,status);
            //执行SQL语句
            int count = pstmt.executeUpdate();

            //处理结果
            System.out.println(count > 0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {

                pstmt.close();
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

改:

/**
     * 修改
     * SQL语句:UPDATE tb_brand SET brand_name = ?,company_name = ?,ordered = ?,description = ?,status = ? WHERE id = ?;
     */
    @Test
    public void testUpdate()
    {
        Connection conn = null;
        PreparedStatement pstmt = null;
        //假设接受到的添加的信息如下:
        String brandName = "网易";
        String companyName = "网易技术有限公司";
        Integer ordered = 1;
        String description = "66666";
        Integer status = 1;
        Integer id = 4;

        try {
            //加载配置文件
            Properties prop = new Properties();
            prop.load(new FileInputStream("D:\\李明茂\\Java学习\\JDBC\\src\\druid.properties"));
            //获取连接池对象
            DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
            //获取数据库连接Connection
            conn = dataSource.getConnection();

            //定义SQL语句
            String sql = "UPDATE tb_brand SET brand_name = ?,company_name = ?,ordered = ?,description = ?,status = ? WHERE id = ?;";

            //获取PreparedStatement对象
            pstmt = conn.prepareStatement(sql);

            //设置参数
            pstmt.setString(1,brandName);
            pstmt.setString(2,companyName);
            pstmt.setInt(3,ordered);
            pstmt.setString(4,description);
            pstmt.setInt(5,status);
            pstmt.setInt(6,id);
            //执行SQL语句
            int count = pstmt.executeUpdate();

            //处理结果
            System.out.println(count > 0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {

                pstmt.close();
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

删:

/**
     * 删除
     * SQL语句:DELETE FROM tb_brand WHERE id = ?;
     */
    @Test
    public void testDelete()
    {
        Connection conn = null;
        PreparedStatement pstmt = null;
        //假设接受到的添加的信息如下:
        Integer id = 4;

        try {
            //加载配置文件
            Properties prop = new Properties();
            prop.load(new FileInputStream("D:\\李明茂\\Java学习\\JDBC\\src\\druid.properties"));
            //获取连接池对象
            DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
            //获取数据库连接Connection
            conn = dataSource.getConnection();

            //定义SQL语句
            String sql = "DELETE FROM tb_brand WHERE id = ?;";

            //获取PreparedStatement对象
            pstmt = conn.prepareStatement(sql);

            //设置参数

            pstmt.setInt(1,id);
            //执行SQL语句
            int count = pstmt.executeUpdate();

            //处理结果
            System.out.println(count > 0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {

                pstmt.close();
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1326544.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Windows操作系统重装【老毛桃、软碟通、硬盘装机以及装机原理介绍】

目录 一、老毛桃装机 1.1 老毛桃介绍 1.2 注意事项 1.3 操作步骤 1.3.1 老毛桃U盘制作 1.3.2 老毛桃u盘启动 1.3.3 老毛桃u盘重装系统 二、软碟通装机 2.1 软碟通介绍 2.2 主要特点及功能 2.3 操作步骤 2.3.1 用软碟通制作U盘安装盘 2.3.2 U盘启动 2.3.3 安装系统…

构建陪诊预约系统:技术实现与用户体验

在医疗服务不断创新的背景下&#xff0c;陪诊预约系统作为一种结合技术与人性化服务的应用&#xff0c;为患者提供了更为便捷和贴心的医疗体验。让我们通过简单的示例代码&#xff0c;了解一下如何构建一个基本的陪诊预约系统。 技术栈选择 在开始构建陪诊预约系统之前&…

【数据结构和算法】子数组最大平均数 I

其他系列文章导航 Java基础合集数据结构与算法合集 设计模式合集 多线程合集 分布式合集 ES合集 文章目录 其他系列文章导航 文章目录 前言 一、题目描述 二、题解 2.1 滑动窗口含义 2.2 滑动窗口一般解法 2.3 方法一&#xff1a;滑动窗口 三、代码 3.1 方法一&#…

qt-C++笔记之app.processEvents()和QApplication::processEvents()的区别

qt-C笔记之app.processEvents()和QApplication::processEvents()的区别 code review! 代码1&#xff1a; QApplication app(argc, argv); app.processEvents(); 代码2: QApplication::processEvents(); 区别 代码1和代码2的区别在于代码1中使用了一个具体的QApplication对…

26--字符流与字节流

1、IO流概述 1.1 什么是IO流 Java中I/O操作主要是指使用java.io包下的内容&#xff0c;进行输入、输出操作。输入也叫做读取数据&#xff0c;输出也叫做作写出数据。我们把这种数据的传输&#xff0c;可以看做是一种数据的流动&#xff0c;按照流动的方向&#xff0c;以内存为…

力扣刷题记录(17)LeetCode:416、1049

416. 分割等和子集 可以将该问题看成是一个背包问题。背包的容量就是nums数组和的一半。我们如果能够将背包装满就意味着可以将数组分割成两个元素和相等的子集。 1.确定dp[i]的含义 索引i表示背包的容量&#xff0c;dp[i]表示当前容量能够装载的最大值 2.确定动态转移方程 …

JS - 设计模式持续学习中

通过例子持续学习JS设计模式中&#xff0c;接下来请跟随我的步伐走进我的学习笔记世界~ 什么是设计模式&#xff1f;我们为什么需要学习设计模式&#xff1f; 设计模式是可以更好解决问题的一种方案。 这意味着什么&#xff1f;如果你开发的项目的功能是固定的&#xff0c;永…

算法通关村第十四关—堆结构(青铜)

堆结构 一、堆的概念和特征 堆是将一组数据按照完全二叉树的存储顺序&#xff0c;将数据存储在一个一维数组中的结构。堆有两种结构&#xff0c;一种称为大顶堆&#xff0c;一种称为小顶堆&#xff0c;如下图。 1.小顶堆&#xff1a;任意节点的值均小于等于它的左右孩子&#…

android 新版studio gradle 里面没有offline 勾选项

studio 右边 gradle 上面有个图标可以点击切换

宏基因组学中基于Kraken2、Blast、ViPhOG和VirSorter等工具分析病毒组的详细流程,包括数据预处理、病毒序列检测、分类和功能注释等步骤

宏基因组学中分析病毒组的详细流程&#xff0c;包括数据预处理、病毒序列检测、分类和功能注释等步骤。 示例代码使用了常用的生物信息学工具&#xff0c;如Kraken2、Blast、ViPhOG和VirSorter等。 1. 数据预处理 质量控制&#xff1a; 使用FastQC进行原始测序数据的质量检查…

机器视觉:AI赋能缺陷检测,铸就芯片产品的大算力与高能效

导言&#xff1a;近年来&#xff0c;国内芯片行业快速发展&#xff0c;市场对芯片需求的不断增大&#xff0c;芯片的缺陷检测压力也越来越大。芯片产品在生产制造过程中&#xff0c;需要经历数道工序&#xff0c;每个生产环节的材料、环境、工艺参数等都有可能造成产品缺陷。不…

低代码:万事俱备,就差一个程序员

前言 低代码技术&#xff0c;作为当前软件开发领域的一颗新星&#xff0c;正在逐渐改变着传统编程的面貌。其核心特点鲜明且富有创新性&#xff0c;如通过直观的拖拽组件来进行软件开发&#xff0c;这种方式极大地降低了编程的复杂性。可视化编程则是将复杂的代码逻辑转化为图…

js 图片 手动上传,并回显

效果展示&#xff1a; 代码&#xff1a; <label for"avatarUpload"><div><img v-if"avatatImageUrl" :src"avatatImageUrl" class"avatar"><img v-else src"../../assets/images/account/avatar-upload.png…

20231221将NanoPC-T4(RK3399)开发板适配Android12的挖掘机并打开AP6398SV

20231221将NanoPC-T4(RK3399)开发板适配Android12的挖掘机并打开AP6398SV 2023/12/21 17:46 SDK使用&#xff1a;rk356x_android12_220722.tgz android12-rk3588-new_20221229_1732toybrick.tgz【TB3588X】 1、【必须更换AP6398SV征集的驱动程序&#xff01;】 Z:\3TB\91rk_an…

Elasticsearch 性能调优基础知识

Elastic Stack 已成为监控任何环境或应用程序的实际解决方案。 从日志、指标和正常运行时间到性能监控甚至安全&#xff0c;Elastic Stack 已成为满足几乎所有监控需求的一体化解决方案。 Elasticsearch 通过提供强大的分析引擎来处理任何类型的数据&#xff0c;成为这方面的基…

Vuex的学习-3

基于Vuex的案例todos&#xff0c;篇幅有点长&#xff0c;可以根据目录将会的地方可以跳过 初始化项目 1.通过vue ui 命令打开可视化面板&#xff0c;创建新项目 2.安装vuex依赖包 3.实现Todos基本布局 课程代码在此&#xff0c;直接复制即可 main.js import Vue from vue …

Seata中AT模式的实现原理02-RM分支事务提交

前言 RM是资源的管理者 处理分支事务的开启和提交回滚 当TM注册完全局事务之后进行分支事务的提交 RM一阶段处理本地事务&#xff0c;主要是在DataSource、Connection、Statement上做文章。 DataSource 创建 项目启动的时候SeataAutoDataSourceProxyCreator为所有DataSource…

通讯录应用程序开发指南

目录 一、前言 二、构建通讯录应用程序 2.1通讯录框架 (1)打印菜单 (2) 联系人信息的声明 (3)创建通讯录 (4)初始化通讯录 2.2功能实现 (1)增加联系人 (2)显示联系人 (3)删除联系人 (4)查找联系人 (5)修改联系人 (6)排序联系人 三、通讯录的优化 3.1 文件存储 …

RUST与RUSTful简介

RUST与RUSTful 1、背景2、RUST的起源3、RUST与RUSTful4、总结 1、背景 随着互联网&#xff08;Internet&#xff09;的发展&#xff0c;越来越多的人开始意识到&#xff0c;网站即软件&#xff0c;而且是一种新型的软件。这种"互联网软件"采用客户端/服务器&#xff…

el-table设置默认选中报错_this.$refs.singleTable.toggleAllSelection is not a function

直接使用以下的方法&#xff0c;报错信息是_this.$refs.singleTable.toggleAllSelection is not a function this.$refs.singleTable.toggleAllSelection()看了网上的解决方法&#xff0c;加了this.$nextTick,代码如下&#xff0c;但还是报错Error in nextTick: "TypeErr…