Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
Java PreparedStatement_创想鸟

Java PreparedStatement

大家好,很高兴再次与大家见面,我是你们的老朋友全栈君。

Java PreparedStatement与Statement类似,是Java JDBC Framework的一部分。它用于对数据库执行CRUD操作。PreparedStatement扩展了Statement接口。由于支持参数化查询,PreparedStatement被认为更为安全,并且可以防止SQL注入攻击。我们可以通过调用Connection的prepareStatement(String query)方法来获取PreparedStatement的实例,如下所示:

// 方法:public PreparedStatement prepareStatement(String query) throws SQLException {}// 使用:Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/customerdb", "root", "root");PreparedStatement ps = con.prepareStatement("select id, firstname, lastname, email, birthdate from tblcustomer");

PreparedStatement的优势:

PreparedStatement不仅可以用于参数化查询,还可以用于普通查询。其查询性能优于Statement。PreparedStatement的实例可以被重复使用,以执行具有不同参数的同一查询。此外,PreparedStatement可以保护应用程序免受SQL注入攻击。

Java PreparedStatement

立即学习“Java免费学习笔记(深入)”;

Java PreparedStatement层次结构

PreparedStatement方法:

我们可以将方法分为不同的类别。

执行查询:

ResultSet executeQuery():此方法用于通过PreparedStatement对象执行读取操作,返回ResultSet实例以获取数据。int executeUpdate():此方法用于执行插入、删除和更新查询,返回一个整数值,表示受查询影响的数据库行数。

将参数值传递给查询:

所有以下方法都有两个参数。第一个参数是参数索引,第二个参数是参数值。void setInt(int parameterIndex, int value):将Integer值设置为指定的参数索引。void setShort(int parameterIndex, short value):将short值设置为指定的参数索引。void setLong(int parameterIndex, long value):将Long值设置为指定的参数索引。void setFloat(int parameterIndex, float value):将Float值设置为指定的参数索引。void setDouble(int parameterIndex, double value):将Double值设置为指定的参数索引。void setBigDecimal(int parameterIndex, BigDecimal value):将BigDecimal值设置为指定的参数索引。void setString(int parameterIndex, String value):将String值设置为指定的参数索引。void setDate(int parameterIndex, Date value):将Date值设置为指定的参数索引。

注意:参数索引值从1开始,所有这些方法都会抛出SQLException。

Java PreparedStatement示例:

我们将使用MySQL数据库来演示PreparedStatement的使用。使用以下DB脚本创建数据库、表和示例数据:

create database customerdb;use customerdb;create table tblcustomer(    id integer AUTO_INCREMENT primary key,    firstname varchar(32),    lastname varchar(32),    email varchar(32),    birthdate datetime);insert into tblcustomer (id,firstname,lastname,email,birthdate) values(1,'Ricky','Smith','ricky@google.com','2001-12-10');

数据库连接信息:

MySql数据库名称:customerdbIP:localhost端口:3306用户名:root密码:root

Maven依赖关系:

            mysql        mysql-connector-java        5.1.48    

使用PreparedStatement获取数据:

在这种情况下,我们将从tblcustomer表中获取具有指定id的行。查询将返回单行。

package com.journaldev.examples;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;public class PreparedStatementDemo {    public static void main(String[] args) throws Exception {        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        int customerId = 1;        String query = "select id, firstname, lastname, email, birthdate from tblcustomer where id = ?";        try {            Class.forName("com.mysql.jdbc.Driver");            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/customerdb", "root", "root");            ps = con.prepareStatement(query);            ps.setInt(1, customerId);            rs = ps.executeQuery();            while (rs.next()) {                System.out.println("Id:" + rs.getInt(1));                System.out.println("First Name:" + rs.getString(2));                System.out.println("Last Name:" + rs.getString("lastname"));                System.out.println("Email:" + rs.getString("email"));                System.out.println("BirthDate:" + rs.getDate("birthdate"));            }        } catch (Exception e) {            e.printStackTrace();        } finally {            rs.close();            ps.close();            con.close();        }    }}

执行步骤:

步骤1:加载JDBC驱动程序。Class.forName("com.mysql.jdbc.Driver") 将JDBC驱动程序加载到内存中。步骤2:获取Connection对象。DriverManager.getConnection("jdbc:mysql://localhost:3306/customerdb", "root", "root");步骤3:从Connection对象获取PreparedStatement实例,并指定要执行的查询。PreparedStatement ps = con.prepareStatement("select id, firstname, lastname, email, birthdate from tblcustomer");PreparedStatement支持参数化查询,其中’?’是查询中的参数。在执行查询之前,需要提供此参数的值。步骤4:提供查询参数的值。int customerId = 1;ps.setInt(1, customerId); setInt(,)方法有两个参数。在上面的示例中,“1”是参数编号,变量customerId是参数的值。步骤5:执行查询。PreparedStatement的executeQuery()方法用于执行选择查询。它将返回ResultSet的实例。如果查询用于插入、更新或删除,则可以使用executeUpdate()步骤6:迭代ResultSet。ResultSet的next()方法用于获取查询输出。步骤7:关闭资源:这是重要的一步。许多开发人员忘记关闭诸如ResultSet、PreparedStatement和Connection之类的资源。这将导致资源泄漏,可能会使您的应用程序崩溃。

程序输出:

Id:1First Name:RickyLast Name:SmithEmail:ricky@google.comBirthDate:2001-12-1

使用PreparedStatement进行插入操作:

在此示例中,我们将使用PreparedStatement在tblcustomer表中执行插入操作。

package com.journaldev.examples;import java.sql.*;import java.text.SimpleDateFormat;public class PrepareStatementInsertDemo {    public static void main(String[] args) throws Exception {        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        String firstname = "matthew";        String lastname = "wade";        String email = "matthew@java.com";        Date birthdate = new Date(new SimpleDateFormat("YYYY-MM-DD").parse("2000-12-12").getTime());        String query = "insert into tblcustomer (id,firstname,lastname,email,birthdate) values(default,?,?,?,?)";        try {            Class.forName("com.mysql.jdbc.Driver");            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/customerdb", "root", "root");            ps = con.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);            ps.setString(1, firstname);            ps.setString(2, lastname);            ps.setString(3, email);            ps.setDate(4, birthdate);            int row = ps.executeUpdate();            System.out.println("No. of Rows inserted:" + row);            rs = ps.getGeneratedKeys();            if (rs.next()) {                System.out.println("Id of new Customer:" + rs.getInt(1));            }        } catch (Exception e) {            e.printStackTrace();        } finally {            rs.close();            ps.close();            con.close();        }    }}

在此示例中,在创建PreparedStatement实例时,我们传递了两个参数。第一个是查询本身,第二个是“Statement.RETURN_GENERATED_KEYS”,这将帮助我们获取新行的主键值。

以下代码用于为插入查询提供参数:

ps.setString(1, firstname);ps.setString(2, lastname);ps.setString(3, email);ps.setDate(4, birthdate);

如前面的程序中所述,executeUpdate()方法用于执行插入操作。它将返回受我们的查询影响的行数。

程序输出:

No. of Rows inserted:1Id of new Customer:2

如果您转到数据库并执行选择查询,您将看到以下结果:

mysql> use customerdb;Database changedmysql> select * from tblcustomer;+----+-----------+----------+------------------+---------------------+| id | firstname | lastname | email            | birthdate           |+----+-----------+----------+------------------+---------------------+|  1 | Ricky     | Smith    | ricky@google.com | 2001-12-10 00:00:00 ||  2 | matthew   | wade     | matthew@java.com | 1999-12-26 00:00:00 |+----+-----------+----------+------------------+---------------------+2 rows in set (0.00 sec)

使用PreparedStatement进行更新操作:

现在我们将执行更新操作。我们将更新电子邮件为“matthew@java.com”的客户的名字和姓氏。这行是在前面的示例中插入的。

package com.journaldev.examples;import java.sql.*;public class PrepareStatementUpdateDemo {    public static void main(String[] args) throws Exception {        Connection con = null;        PreparedStatement ps = null;        String email = "matthew@java.com";        String newFirstname = "john";        String newLastname = "smith";        String query = "update tblcustomer set firstname = ?,lastname =? where email = ?";        try {            Class.forName("com.mysql.jdbc.Driver");            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/customerdb", "root", "root");            ps = con.prepareStatement(query);            ps.setString(1, newFirstname);            ps.setString(2, newLastname);            ps.setString(3, email);            int row = ps.executeUpdate();            System.out.println("No. of Rows Updated:" + row);            if (row == 1) {                String selectQuery = "select id,firstname,lastname,email,birthdate from tblcustomer where email=?";                try (PreparedStatement selStatement = con.prepareStatement(selectQuery);) {                    selStatement.setString(1, email);                    ResultSet rs = selStatement.executeQuery();                    if (rs.next()) {                        System.out.println("Id:" + rs.getInt(1));                        System.out.println("First Name:" + rs.getString(2));                        System.out.println("Last Name:" + rs.getString("lastname"));                        System.out.println("Email:" + rs.getString("email"));                        System.out.println("BirthDate:" + rs.getDate("birthdate"));                    }                    rs.close();                }            }        } catch (Exception e) {            e.printStackTrace();        } finally {            ps.close();            con.close();        }    }}

了解程序:

在上面的示例中,我们在查询中有三个参数。第一个是新名字,第二个是新姓氏,第三个是客户的电子邮件。

以下代码行将此参数的值提供给PreparedStatement:

ps.setString(1, newFirstname);ps.setString(2, newLastname);ps.setString(3, email);

executeUpdate()方法用于执行更新查询。它将返回查询更新的行数。

程序输出:

No. of Rows Updated:1Id:2First Name:johnLast Name:smithEmail:matthew@java.comBirthDate:1999-12-26

您可以使用SQL查询在数据库中检查更新:

mysql> select * from tblcustomer;+----+-----------+----------+------------------+---------------------+| id | firstname | lastname | email            | birthdate           |+----+-----------+----------+------------------+---------------------+|  1 | Ricky     | Smith    | ricky@google.com | 2001-12-10 00:00:00 ||  2 | john      | smith    | matthew@java.com | 1999-12-26 00:00:00 |+----+-----------+----------+------------------+---------------------+2 rows in set (0.00 sec)

使用PreparedStatement进行删除操作:

现在我们将删除电子邮件为“matthew@java.com”的客户记录。

package com.journaldev.examples;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;public class PrepareStatementDeleteDemo {    public static void main(String[] args) throws Exception {        Connection con = null;        PreparedStatement ps = null;        String email = "matthew@java.com";        String query = "delete from tblcustomer where email = ?";        try {            Class.forName("com.mysql.jdbc.Driver");            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/customerdb", "root", "root");            ps = con.prepareStatement(query);            ps.setString(1, email);            int row = ps.executeUpdate();            System.out.println("No. of Rows Deleted:" + row);        } catch (Exception e) {            e.printStackTrace();        } finally {            ps.close();            con.close();        }    }}

PreparedStatement中的批处理方法:

void addBatch():此方法用于将参数集添加到此PreparedStatement对象的批处理中,以更新多行。int[] executeBatch():此方法从PreparedStatement对象的批处理中执行所有SQL查询,并返回更新计数数组。如果此方法无法执行,并且JDBC驱动程序可能会也可能不会继续处理剩余的批处理,则会抛出BatchUpdateException。

使用PreparedStatement的批量/批量操作:

package com.journaldev.examples;import java.sql.*;import java.text.SimpleDateFormat;public class PrepareStatementBatchDemo {    public static void main(String[] args) throws Exception {        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD");        String query = "insert into tblcustomer (id,firstname,lastname,email,birthdate) values(default,?,?,?,?)";        try {            Class.forName("com.mysql.jdbc.Driver");            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/customerdb", "root", "root");            ps = con.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);            // 1st Insert            ps.setString(1, "Ross");            ps.setString(2, "Southee");            ps.setString(3, "ross@java.com");            ps.setDate(4, new Date(sdf.parse("2000-12-12").getTime()));            ps.addBatch();            // 2nd Insert            ps.setString(1, "Mayank");            ps.setString(2, "Kohli");            ps.setString(3, "mayank@java.com");            ps.setDate(4, new Date(sdf.parse("2005-12-12").getTime()));            ps.addBatch();            // 3rd Insert            ps.setString(1, "Tom");            ps.setString(2, "Patel");            ps.setString(3, "tom@java.com");            ps.setDate(4, new Date(sdf.parse("1995-12-12").getTime()));            ps.addBatch();            // Execution            int[] rows = ps.executeBatch();            for (int row : rows) {                System.out.println("No. of Rows inserted:" + row);            }            rs = ps.getGeneratedKeys();            while (rs.next()) {                System.out.println("Id of new Customer:" + rs.getInt(1));            }        } catch (Exception e) {            e.printStackTrace();        } finally {            rs.close();            ps.close();            con.close();        }    }}

在上面的示例中,我们分批插入了3个客户记录。批量插入多行比单行插入更有效。addBatch()方法将数据添加到批处理中。executeBatch()执行批处理中的所有查询。

输出:

No. of Rows inserted:1No. of Rows inserted:1No. of Rows inserted:1Id of new Customer:10Id of new Customer:11Id of new Customer:12

您可以通过此链接下载完整的Java项目。

参考:Java文档

发布者:全栈程序员栈长,转载请注明出处:https://www.php.cn/link/dbe2b7e940f999dbd70a13eb1da19ea1 原文链接:https://www.php.cn/link/c8377ad2a50fb65de28b11cfc628d75c

以上就是Java PreparedStatement的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/27265.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
《空洞骑士:丝之歌》公布新简中补丁交付时间!建议先用同人汉化
上一篇 2025年11月2日 23:20:38
Java泛型与多态能否结合使用 如何实现通用接口
下一篇 2025年11月2日 23:22:40

相关推荐

  • 锚定AI终端存储市场,康盈半导体连发三款新品

    锚定AI终端存储市场,康盈半导体连发三款新品锚定AI终端存储市场,康盈半导体连发三款新品锚定AI终端存储市场,康盈半导体连发三款新品锚定AI终端存储市场,康盈半导体连发三款新品

    ☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜ 三款新品聚焦AI存储需求 在最新举行的产品发布会上,康盈半导体正式推出三款专为AI应用场景打造的全新存储解决方案,覆盖嵌入式存储与高性能固态硬盘等多个品类,旨在满足多样化AI终端对高效、紧凑、低…

    2026年9月21日 用户投稿
    000
  • 数据库运维开发环境的调试模式演进

    数据库运维开发环境的调试模式演进数据库运维开发环境的调试模式演进数据库运维开发环境的调试模式演进数据库运维开发环境的调试模式演进

    这是学习笔记的第2393篇文章。 昨日,同事反馈了一个问题,原本的办公机环境中的虚拟机可以将办公机的IP暴露出来,提供数据库运维的API服务。例如,办公机的IP为192.168.10.100,而使用VirtualBox的虚拟机采用主机模式,其IP可能为192.168.56.100,那么192.168…

    2026年9月21日 用户投稿
    000
  • linux内核定时器实验

    linux内核定时器实验linux内核定时器实验linux内核定时器实验linux内核定时器实验

    大家好,又见面了,我是你们的朋友全栈君。 文章目录一、linux时间管理和内核定时器简介1.内核时间管理简介2.内核定时器简介1.init_timer 函数2.add_timer 函数3.del_timer 函数4.del_timer_sync 函数5.mod_timer 函数3.linux内核短延…

    2026年9月21日 用户投稿
    000
  • MySQL数据库日志审计与合规性实现_保护敏感数据与满足法规需求

    MySQL数据库日志审计与合规性实现_保护敏感数据与满足法规需求MySQL数据库日志审计与合规性实现_保护敏感数据与满足法规需求MySQL数据库日志审计与合规性实现_保护敏感数据与满足法规需求MySQL数据库日志审计与合规性实现_保护敏感数据与满足法规需求

    mysql日志审计是合规性的基石,因为它提供了数据库操作的完整证据链,记录用户身份、操作类型和时间戳等关键信息,满足gdpr、hipaa等法规要求,并支持事后追溯与事前震慑。1. mysql自身提供错误日志、通用查询日志、慢查询日志和二进制日志,其中通用查询日志记录所有sql语句,二进制日志用于数据…

    2026年9月21日 用户投稿
    000
  • WordPress插件定制:使用Filter Hook修改邮件通知接收者

    本教程将指导您如何在WordPress中利用Filter Hook定制插件行为,特别是修改第三方插件的邮件通知接收者。我们将详细讲解如何识别目标Filter、理解其参数,并正确编写回调函数来拦截或修改数据,以实现自定义的邮件发送逻辑,避免因参数不匹配导致的错误。 WordPress Hook机制概览…

    2026年9月21日
    100
  • VSCode编写Java代码方法_VSCode搭建Java开发环境实战教程

    答案:在VSCode中配置Java开发环境需安装JDK并设置环境变量,再安装VSCode及Java扩展包,即可实现Java项目的创建、编写、运行与调试。它轻量、启动快,支持多语言和丰富扩展,集成Maven/Gradle,适合日常开发。 在VSCode里编写Java代码,说白了,就是把这个轻量级的代码…

    2026年9月21日
    000
  • JavaScript中的模块联邦如何实现微前端的代码共享?

    模块联邦通过运行时动态加载实现微前端代码共享,无需打包公共依赖。使用 ModuleFederationPlugin 配置 name、remotes、exposes 和 shared,使应用可暴露或引入远程模块,支持组件、工具函数及状态管理共享,提升复用性并减少冗余。 模块联邦通过在构建时让不同应用直…

    2026年9月21日
    200
  • Swoole如何实现一个UDP服务器

    答案:使用Swoole可轻松创建高性能UDP服务器。通过new SwooleServer()设置UDP套接字,监听Packet事件接收数据,利用sendto()回复客户端;结合set()配置worker_num等参数优化性能,配合PHP UDP客户端测试通信,适用于高并发、低延迟场景。 使用Swoo…

    2026年9月21日
    100
  • MySQL执行计划中的Extra字段代表什么_怎么看优化空间?

    MySQL执行计划中的Extra字段代表什么_怎么看优化空间?MySQL执行计划中的Extra字段代表什么_怎么看优化空间?MySQL执行计划中的Extra字段代表什么_怎么看优化空间?MySQL执行计划中的Extra字段代表什么_怎么看优化空间?

    在 mysql 查询优化中,执行计划的 extra 字段用于说明查询执行时的额外操作,常见的值包括:1. using filesort 表示需要额外排序,应尽量通过建立索引避免;2. using temporary 表示使用了临时表,常见于 group by 或复杂 join,需优化减少其使用;3.…

    2026年9月21日 用户投稿
    100
  • 如何通过tracert命令追踪数据包从本地到目标服务器的完整路径?

    打开命令提示符,输入cmd并回车;2. 执行tracert 目标地址命令追踪路径;3. 查看每跳响应时间与IP,分析延迟变化定位网络瓶颈;4. 注意部分节点可能因防火墙不响应导致超时。 使用 tracert(Windows 系统)命令可以追踪数据包从你的计算机到目标服务器所经过的每一跳网络节点,帮助…

    2026年9月21日
    1000
  • Linux interfaces 虚拟网络类型了解01

    Linux interfaces 虚拟网络类型了解01Linux interfaces 虚拟网络类型了解01Linux interfaces 虚拟网络类型了解01Linux interfaces 虚拟网络类型了解01

    在osi模型的定义中,数据链路层和物理层,以及传输层和网络层执行的任务在概念上相似:它们都提供了数据传输的方式,即沿着特定路径将数据从源点传输到目的地的方法。然而,数据链路层和物理层负责跨物理路径的通信服务,而传输层和网络层则提供由多个数据链路组成的逻辑路径或虚拟路径的通信服务。 Bridge操作指…

    2026年9月21日 用户投稿
    000
  • 如何在Java中理解Java I/O与NIO机制

    传统I/O是阻塞式流模型,适用于低并发场景;NIO基于缓冲区与通道,支持非阻塞和多路复用,适合高并发网络应用,核心区别在于线程模型与资源利用率。 Java中的I/O(输入/输出)与NIO(New I/O)是处理数据读写的核心机制,理解它们的区别和使用场景对开发高性能应用至关重要。传统I/O基于流模型…

    2026年9月21日
    100
  • JavaScript中的尾调用优化(TCO)在ES6中如何工作?

    尾调用是指函数的最后一个动作调用另一个函数,ES6引入尾调用优化以重用栈帧、避免内存溢出,支持真正的尾递归,如阶乘函数通过累积参数实现。 尾调用优化(Tail Call Optimization, TCO)是ES6引入的一项语言特性,目的是在特定条件下重用函数调用栈帧,避免不必要的内存增长,从而支持…

    2026年9月21日
    200
  • MySQL数据分库分表如何设计_避免性能瓶颈的方法?

    MySQL数据分库分表如何设计_避免性能瓶颈的方法?MySQL数据分库分表如何设计_避免性能瓶颈的方法?MySQL数据分库分表如何设计_避免性能瓶颈的方法?MySQL数据分库分表如何设计_避免性能瓶颈的方法?

    分库分表设计需注意分片键选择、分片数量控制、避免跨库查询及完善运维体系。一,优先选择高频查询字段作为分片键,如用户id,避免使用时间戳以防写热点;二,初期合理分片(如4~8库,每库4~8表),预留扩容空间并根据数据总量反推分片数;三,尽量避免跨库查询,可通过冗余数据、异步汇总或强制路由优化;四,配套…

    2026年9月21日 用户投稿
    100
  • 抖音蝴蝶号无人直播带货操作流程及注意事项

    抖音蝴蝶号无人直播带货操作流程及注意事项抖音蝴蝶号无人直播带货操作流程及注意事项抖音蝴蝶号无人直播带货操作流程及注意事项抖音蝴蝶号无人直播带货操作流程及注意事项

    “抖音蝴蝶号无人直播带货”是一种通过自动化或半自动化技术实现的直播销售模式。①其核心在于摆脱真人主播限制,实现24小时不间断直播,提升效率与流量利用率;②关键步骤包括明确账号定位与商品选择、准备高质量且丰富的内容素材、利用虚拟人或预录内容实现直播推流、结合智能客服模拟评论区互动;③优势在于降低人力成…

    2026年9月21日 用户投稿
    600
  • VSCode侧边栏怎么去掉_VSCode侧边栏隐藏教程

    隐藏VSCode侧边栏可通过Ctrl + B(Windows/Linux)或Cmd + B(macOS)快捷键快速切换,也可通过菜单栏“视图 > 外观 > 切换侧边栏可见性”或命令面板执行“View: Toggle Sidebar Visibility”实现。推荐使用快捷键操作,效率最高…

    2026年9月21日
    100
  • 如何限制Linux用户cron任务 /etc/cron.deny使用技巧

    如何限制Linux用户cron任务 /etc/cron.deny使用技巧如何限制Linux用户cron任务 /etc/cron.deny使用技巧如何限制Linux用户cron任务 /etc/cron.deny使用技巧如何限制Linux用户cron任务 /etc/cron.deny使用技巧

    要限制linux用户执行cron任务,可编辑/etc/cron.deny文件,每行添加一个需禁止的用户名,保存后立即生效;若需更细粒度控制,可使用pam_time模块;此外,还可通过sudoers文件、chroot环境、linux capabilities、apparmor或selinux等方法限制…

    2026年9月21日 用户投稿
    200
  • MySQL用户权限体系配置思路_Sublime中编辑多用户分权管理脚本

    MySQL用户权限体系配置思路_Sublime中编辑多用户分权管理脚本MySQL用户权限体系配置思路_Sublime中编辑多用户分权管理脚本MySQL用户权限体系配置思路_Sublime中编辑多用户分权管理脚本MySQL用户权限体系配置思路_Sublime中编辑多用户分权管理脚本

    最小权限原则是mysql用户权限配置的核心,确保每个用户仅拥有必要权限以提升安全性与可维护性。1.明确需求:根据用户角色分配如只读、增删改查或结构修改权限;2.创建用户并编写sql脚本进行权限管理,替代手动输入命令,提高效率与一致性;3.使用sublime text等编辑器提升脚本编写效率,利用语法…

    2026年9月21日 用户投稿
    100
  • 音乐文件占用空间太多怎么办_音乐文件占用空间太多如何整理详细指南

    解决音乐文件占空间问题的关键是压缩与整理:先用软件或在线工具降低比特率压缩体积,再按场景分类、利用元数据自动归集,并通过听歌片段和BPM判断保留内容,避免重复与误删。 音乐文件占空间太多,核心解决办法就两条:一是压缩单个文件体积,二是通过有效分类管理提升使用效率。直接删歌不是长久之计,学会整理和优化…

    2026年9月21日
    000
  • 升级X86架构性能大提升!极空间Z2 Ultra图赏

    升级X86架构性能大提升!极空间Z2 Ultra图赏升级X86架构性能大提升!极空间Z2 Ultra图赏升级X86架构性能大提升!极空间Z2 Ultra图赏升级X86架构性能大提升!极空间Z2 Ultra图赏

    10月23日,极空间正式推出全新双盘位nas产品——极空间z2 ultra,官方售价为1899元,参与国家补贴后仅需1457元,性价比进一步提升。 此次发布的Z2 Ultra最大的亮点在于采用X86架构处理器,相较以往使用的ARM平台,性能实现飞跃式提升,运行速度显著加快。更重要的是,新架构对Doc…

    2026年9月21日 用户投稿
    300

发表回复

登录后才能评论
关注微信