当前位置:网站首页>JDBC introduction
JDBC introduction
2022-07-06 15:11:00 【Hand pluckable Xinchen】
1,JDBC Concept
Java Database Connectivity(JDBC):Java Access to the database solution .
JDBC Defines a set of interfaces , That is to access the general database API, Different database manufacturers implement these interfaces according to the characteristics of their respective databases .
JDBC You want to access different databases in the same way , Let the specific database operation have nothing to do with the implementation of the database manufacturer , Thus in
Easily switch between different databases .
2,JDBC Related class interface
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(' Zhang San ','2022-1-1',' male ','100')";
Statement statm = conn.createStatement();
int ret = statm.executeUpdate(sql); // perform DML sentence ( add to , Delete , modify ), Return value int
//ResultSet rs = stmt.executeQuery(sql); // perform DQL sentence ( Inquire about ), Return value ResultSet
if(ret > 0) {
System.out.println(" Execution succeeded ");
}else {
System.out.println(" Execution failed ");
}
(5) Release resources
statm.close();
conn.close();
边栏推荐
- Currently, mysql5.6 is used. Which version would you like to upgrade to?
- Iterators and generators
- 全网最详细的postman接口测试教程,一篇文章满足你
- ucore lab6 调度器 实验报告
- Want to learn how to get started and learn software testing? I'll give you a good chat today
- Global and Chinese market of maleic acid modified rosin esters 2022-2028: Research Report on technology, participants, trends, market size and share
- MySQL数据库(一)
- Daily code 300 lines learning notes day 9
- Cadence physical library lef file syntax learning [continuous update]
- ucore lab8 文件系统 实验报告
猜你喜欢
Video scrolling subtitle addition, easy to make with this technique
全网最详细的postman接口测试教程,一篇文章满足你
Nest and merge new videos, and preset new video titles
150 common interview questions for software testing in large factories. Serious thinking is very valuable for your interview
Four methods of exchanging the values of a and B
Cc36 different subsequences
How to rename multiple folders and add unified new content to folder names
Daily code 300 lines learning notes day 9
安全测试入门介绍
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.
想跳槽?面试软件测试需要掌握的7个技能你知道吗
STC-B学习板蜂鸣器播放音乐2.0
Common Oracle commands
Dlib detects blink times based on video stream
ucore lab7 同步互斥 实验报告
Statistics 8th Edition Jia Junping Chapter 1 after class exercises and answers summary
[pointer] octal to decimal
The common methods of servlet context, session and request objects and the scope of storing data in servlet.
HackTheBox-Emdee five for life
Global and Chinese market of portable and handheld TVs 2022-2028: Research Report on technology, participants, trends, market size and share
Servlet
[issue 18] share a Netease go experience
UCORE lab7 synchronous mutual exclusion experiment report
ucore lab5用户进程管理 实验报告
Cadence physical library lef file syntax learning [continuous update]
[pointer] solve the last person left
How to transform functional testing into automated testing?
Four methods of exchanging the values of a and B
Es full text index