当前位置:网站首页>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();边栏推荐
- Don't you even look at such a detailed and comprehensive written software test question?
- How to solve the poor sound quality of Vos?
- If the position is absolute, touchablehighlight cannot be clicked - touchablehighlight not clickable if position absolute
- 软件测试方法有哪些?带你看点不一样的东西
- How to transform functional testing into automated testing?
- Vysor uses WiFi wireless connection for screen projection_ Operate the mobile phone on the computer_ Wireless debugging -- uniapp native development 008
- Quaternion -- basic concepts (Reprint)
- Build your own application based on Google's open source tensorflow object detection API video object recognition system (I)
- Four methods of exchanging the values of a and B
- Function: find the maximum common divisor and the minimum common multiple of two positive numbers
猜你喜欢

Nest and merge new videos, and preset new video titles

接口测试面试题及参考答案,轻松拿捏面试官

Logstack introduction and deployment -- elasticstack (elk) work notes 019

C language do while loop classic Level 2 questions
![[200 opencv routines] 98 Statistical sorting filter](/img/ba/9097df20f6d43dfce9fc1e374e6597.jpg)
[200 opencv routines] 98 Statistical sorting filter

Keil5 MDK's formatting code tool and adding shortcuts

In Oracle, start with connect by prior recursive query is used to query multi-level subordinate employees.

Cc36 different subsequences

后台登录系统,JDBC连接数据库,做小案例练习
![[HCIA continuous update] advanced features of routing](/img/05/a9ed32ec8c19b236355d48f7c2ad80.jpg)
[HCIA continuous update] advanced features of routing
随机推荐
Global and Chinese market of barrier thin film flexible electronics 2022-2028: Research Report on technology, participants, trends, market size and share
ByteDance ten years of experience, old bird, took more than half a year to sort out the software test interview questions
Pointeurs: maximum, minimum et moyenne
Global and Chinese markets of cobalt 2022-2028: Research Report on technology, participants, trends, market size and share
软件测试方法有哪些?带你看点不一样的东西
Stc-b learning board buzzer plays music
函数:求两个正数的最大公约数和最小公倍
Build your own application based on Google's open source tensorflow object detection API video object recognition system (II)
数字电路基础(一)数制与码制
[pointer] find the length of the string
Fundamentals of digital circuits (I) number system and code system
几款开源自动化测试框架优缺点对比你知道吗?
Pointer -- eliminate all numbers in the string
想跳槽?面试软件测试需要掌握的7个技能你知道吗
How to rename multiple folders and add unified new content to folder names
Fundamentals of digital circuits (III) encoder and decoder
ucore lab1 系统软件启动过程 实验报告
Fundamentals of digital circuit (V) arithmetic operation circuit
[200 opencv routines] 98 Statistical sorting filter
[HCIA continuous update] working principle of static route and default route