当前位置:网站首页>JDBC介绍
JDBC介绍
2022-07-06 09:25:00 【手可摘鑫晨】
1,JDBC概念
Java Database Connectivity(JDBC):Java访问数据库的解决方案。
JDBC定义了一套接口,即访问数据库的通用API,不同数据库厂商根据各自数据库的特点去实现这些接口。
JDBC希望用相同的方式访问不同的数据库,让具体的数据库操作与数据库厂商实现无关,从而在
不同数据库之间轻易的进行切换。
2,JDBC相关类接口
Class.forName("com.mysql.cj.jdbc.Driver");String url = "jdbc:mysql://localhost:3306/dayone?serverTimezone=GMT";
String user = "root";
String pwd = "123456";
Connection conn = DriverManager.getConnection(url, user, pwd);String sql = "insert into student(sname,birthday,ssex,classid) values('张三','2022-1-1','男','100')";
Statement statm = conn.createStatement();int ret = statm.executeUpdate(sql); //执行DML语句(添加,删除,修改),返回值int
//ResultSet rs = stmt.executeQuery(sql); //执行DQL语句(查询),返回值ResultSet
if(ret > 0) {
System.out.println("执行成功了");
}else {
System.out.println("执行失败了");
}(5)释放资源
statm.close();
conn.close();边栏推荐
- 王爽汇编语言学习详细笔记一:基础知识
- 数字电路基础(五)算术运算电路
- If the position is absolute, touchablehighlight cannot be clicked - touchablehighlight not clickable if position absolute
- 后台登录系统,JDBC连接数据库,做小案例练习
- Wang Shuang's detailed learning notes of assembly language II: registers
- Stc-b learning board buzzer plays music
- [200 opencv routines] 98 Statistical sorting filter
- Fundamentals of digital circuits (I) number system and code system
- Matplotlib绘图快速入门
- [pointer] find the largest string
猜你喜欢

5 minutes to master machine learning iris logical regression classification

How to transform functional testing into automated testing?

Fundamentals of digital circuits (I) number system and code system

Description of Vos storage space, bandwidth occupation and PPS requirements

Sleep quality today 81 points

王爽汇编语言学习详细笔记一:基础知识

The common methods of servlet context, session and request objects and the scope of storing data in servlet.

What level do 18K test engineers want? Take a look at the interview experience of a 26 year old test engineer

Install and run tensorflow object detection API video object recognition system of Google open source

Fundamentals of digital circuit (V) arithmetic operation circuit
随机推荐
Global and Chinese markets for GaN on diamond semiconductor substrates 2022-2028: Research Report on technology, participants, trends, market size and share
Quaternion -- basic concepts (Reprint)
Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code
Réponses aux devoirs du csapp 7 8 9
Keil5-MDK的格式化代码工具及添加快捷方式
几款开源自动化测试框架优缺点对比你知道吗?
Dlib detects blink times based on video stream
Leetcode simple question: check whether the numbers in the sentence are increasing
Function: find 1-1/2+1/3-1/4+1/5-1/6+1/7-... +1/n
自动化测试你必须要弄懂的问题,精品总结
Query method of database multi table link
[oiclass] maximum formula
后台登录系统,JDBC连接数据库,做小案例练习
Global and Chinese market of goat milk powder 2022-2028: Research Report on technology, participants, trends, market size and share
Daily code 300 lines learning notes day 9
What is the transaction of MySQL? What is dirty reading and what is unreal reading? Not repeatable?
Global and Chinese market of barrier thin film flexible electronics 2022-2028: Research Report on technology, participants, trends, market size and share
CSAPP homework answers chapter 789
About the garbled code problem of superstar script
[HCIA continuous update] advanced features of routing