当前位置:网站首页>【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。
- 关闭资源。
边栏推荐
- [database] complete SQL statement
- Intelligent robots and intelligent systems (Professor Zheng Zheng of Dalian University of Technology) -- 2. Mobile Robot Perception
- Error reported by Nacos: error Nacos failed to start, please see d:\nacos\logs\nacos log for more details.
- [wechat applet development] (II) wechat native bottom tabbar configuration
- Kotlin coroutine (I): foundation and deepening
- Go: Gin basicauth Middleware
- As skillfully uses idea annotation to improve collaboration / development efficiency
- Detailed explanation of wechat applet page configuration and sitemap configuration parameters
- 图新地球:Revit建模的rvt格式BIM模型如何带着纹理精准匹配地图
- Workspace creation
猜你喜欢

Decision tree - ID3, C4.5, cart
![[interview] Why do you need foreach with the for cycle?](/img/f1/3e2b933b91436849eaeb3812c41679.png)
[interview] Why do you need foreach with the for cycle?

About the big hole of wechat applet promise

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

Opencv project practice - credit card recognition

Wechat applet host environment, applet architecture, concise operation structure

SVG 从入门到后悔,怎么不早点学起来(图解版)

Qt|字符串生成二维码功能

Image feature Harris corner detection

我在微软的这六个月
随机推荐
[MySQL] installation tutorial and master-slave configuration
Continuous learning, lifelong learning, episodic memory, memory module paper summary -- gradient episodic memory promotes continuous learning
[linear algebra] deeply understand matrix multiplication, symmetric matrix, positive definite matrix
栈/堆/队列刷题(下)
33-SparkSql的介绍、DataFrame和DataSet
My six months at Microsoft
[shutter] the shutter doctor reports an error
Digital twin demonstration project -- Talking about simple pendulum (3) solid model exploration
【golang从入门到实践】学生成绩管理系统
Learning dynamic Siamese network for visual object tracking full text translation
RBM contrast divergence
P1305新二叉树题解
Error lnk2019: unresolved external symbol [email protected]
*Code understanding *numpy basic (plus code) that must be understood
The difference between online learning and offline learning
Anaconda cannot shut down the method of forced shutdown
JSON extractor use in JMeter
[tools] a few lines of code can realize complex excel import and export tool classes, which is really strong!!!
Natural language processing hanlp
Database system - Basic Concepts