当前位置:网站首页>【JDBC】JDBC经典面试题,持续更新中......
【JDBC】JDBC经典面试题,持续更新中......
2022-07-24 08:15:00 【Sivan_Xin】
什么是JDBC?
JDBC的全称是Java DataBase Connection。
也就是Java获取数据库连接,通过使用JDBC相关的接口和类。我们可以用它来连接数据库,执行SQL语句等等。
什么是JDBC连接?如何获取数据库/JDBC连接?
JDBC连接是主机和数据库服务器建立的一个会话。
获取JDBC链接主要分为两步:
1. 注册并加载驱动。调用Class.forName()方法。驱动类会注册到DriverManager类中,并且加载到内存里。
2. 调用DriverManager类的getConnection方法。传入数据库连接的url,用户名,密码,就可以获取到连接对象。
JDBC是如何实现Java程序和JDBC驱动的松耦合的?
只有一种情况,才会涉及JDBC驱动,就是利用Class.forName反射机制来注册并加载驱动时。
其余操作全部都是Java程序调用JDBC接口来完成。这样使应用程序和驱动程序隔离,如果要改变数据库就变得简单了。
JDBC连接数据库的步骤?对数据进行操作?
- 注册并加载驱动。
- 使用DriverManager获取连接。
- 预编译sql语句,返回PreparedStatement。
- 填充占位符。
- 执行数据库操作。
- 处理结果集ResultSet。
- 关闭资源。
边栏推荐
- [interview] Why do you need foreach with the for cycle?
- A knight's journey
- DGL库中一些函数或者方法的介绍
- Hegong sky team vision training Day2 - traditional vision, opencv basic operation
- Kotlin coroutine (I): foundation and deepening
- Installation and use of CONDA
- how to add square on screenshot
- Common DOS commands
- 避坑,职场远离PUA,PUA常见的套路与话术你得了解一下!
- Wechat payment V3 version of openresty implementation and pit avoidance Guide (service side)
猜你喜欢

避坑,职场远离PUA,PUA常见的套路与话术你得了解一下!

SVG 从入门到后悔,怎么不早点学起来(图解版)
![[Linux] Oracle VirtualBox installation CentOS 8](/img/fc/ea1070b93d3f1dbc52e60045834ea9.png)
[Linux] Oracle VirtualBox installation CentOS 8

The code is tired. Stop and enjoy the top color matching~

Avoid pitfalls and stay away from PUA in the workplace. You need to know the common routines and scripts of PUA!

*Yolo5 learning * data experiment based on yolo5 face combined with attention model se

My six months at Microsoft

Learning to track at 100 FPS with deep progression networks

Robot operation continuous learning thesis (1) original text reading and Translation -- primitive generation strategy learning without catastrophic forgetting in robot operation

Markdown basic grammar learning
随机推荐
FPGA integrated project - image edge detection system
Figure New Earth: how the RVT format BIM model modeled by Revit can accurately match the map with texture
Error reported by Nacos: error Nacos failed to start, please see d:\nacos\logs\nacos log for more details.
Several development frameworks based on openresty
Hegong sky team vision training day4 - traditional vision, contour recognition
*Code understanding * common function parsing in pytoch
Error lnk2019: unresolved external symbol [email protected]
Cmake binary installation
【golang从入门到实践】学生成绩管理系统
About the big hole of wechat applet promise
Telecom Customer Churn Prediction challenge baseline [AI competition]
Wechat official account configures custom menu jump applet and automatically replies to jump applet
WXS syntax reference -wxs module
Detailed explanation of wechat applet page configuration and sitemap configuration parameters
Default risk early warning preliminary competition scheme of bond issuing enterprises [AI competition]
图新地球:Revit建模的rvt格式BIM模型如何带着纹理精准匹配地图
1005. Maximized array sum after K negations
[Linux] Oracle VirtualBox installation CentOS 8
Solve the problem that Anaconda navigator cannot be opened
Implementation of unity hub free version