当前位置:网站首页>Statement执行update语句
Statement执行update语句
2022-08-02 00:02:00 【Camellia——】
package com.lin.jdbc_01;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
/*
* 使用Statement操作DML,updata语句
* */
public class JdbcDemo1 {
public static void main(String[] args) throws Exception {
//1)注册驱动
Class.forName("com.mysql.jdbc.Driver");
// 2)获取数据库连接对象
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb_01", "root", "123456");
// 3)准备sql
String sql="update stu set name='王五' where id=4;";
// 4)创建执行对象
Statement stmt=conn.createStatement();
// 5)执行
int count=stmt.executeUpdate(sql);
System.out.println(count);
// 6)释放资源
stmt.close();
conn.close();
}
}
边栏推荐
- JSP out.write()方法具有什么功能呢?
- JSP out.println()方法具有什么功能呢?
- els 方块变形判断。
- Excel导入和导出
- 【三子棋】C语言实现简易三子棋
- After an incomplete recovery, the control file has been created or restored, the database must be opened with RESETLOGS, interpreting RESETLOGS.
- 扑克牌问题
- JSP out.print()和out.write()方法的不同之处
- 不了解SynchronousQueue?那ArrayBlockingQueue和LinkedBlockingQueue不会也不知道吧?
- security cross-domain configuration
猜你喜欢
随机推荐
How to get the best power efficiency in Windows 11?
C语言七夕来袭!是时候展现专属于程序员的浪漫了!
JSP如何使用page指令让JSP文件支持中文编码呢?
基于数据驱动的变电站巡检机器人自抗扰控制
认识USB、Type-C、闪电、雷电接口
NFT工具合集
TCL:在Quartus中使用tcl脚本语言进行管脚约束
07-SDRAM :FIFO控制模块
After an incomplete recovery, the control file has been created or restored, the database must be opened with RESETLOGS, interpreting RESETLOGS.
[Headline] Written test questions - minimum stack
【Leetcode】470. Implement Rand10() Using Rand7()
146. LRU 缓存
多御安全浏览器android版更新至1.7,改进加密协议
工件SSMwar exploded 部署工件时出错。请参阅服务器日志了解详细信息
一篇永久摆脱Mysql时区错误问题,idea数据库可视化插件配置
利用“栈”快速计算——逆波兰表达式
当奈飞的NFT忘记了Web2的业务安全
What is it like to trade for a living?
ES中SQL查询详解
JSP out.write()方法具有什么功能呢?