当前位置:网站首页>JDBC quick start
JDBC quick start
2022-07-20 21:52:00 【Soup key】
Catalog
JDBC(Java DataBase connectivity Java Database connection )
The following steps are carried out at the code
JDBC The concept of
JDBC(Java DataBase connectivity Java Database connection )
- It's one for execution SQL Of the statement Java API
- It can provide unified access to a variety of relational databases
- It's used by a group Java Language written classes and interfaces composed of
JDBC The essence of
- In fact, that is Java An official set of specifications ( Interface )
- Used to help developers quickly connect different relational databases
JDBC Quick start
JDBC Quick start program
- 1. Import jar package
- 2. Registration drive
- 3. Get database connection
- 4. Get the performer object
- 5. perform SQL Statement and return the result
- 6. Processing results
- 7. Release resources
Import jar package
- Decompress the files downloaded from the official website
- Open folder
- Will be with .jar Copy the ending file to idea in
- Create a new folder first , It is specially used for storing third parties jar package
- Copy the copy just now jar Put the bag in
- Right click to add it to the reference class library
The following steps are carried out at the code
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class jdbcdemo01 { public static void main(String []args) throws Exception{ //2. Registration drive Class.forName("com.mysql.jdbc.Driver"); //3. Get the connection Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/dp1","root","109923"); //4. Get execution object Statement stat =con.createStatement(); //5. perform sql sentence , And receive the results String sql = "SELECT * FROM city"; ResultSet rs = stat.executeQuery(sql); //6. Processing results while(rs.next()){ System.out.println(rs.getInt("id")+"\t"+rs.getString("name")); } //7. Release resources con.close(); stat.close(); rs.close(); } }
边栏推荐
- College student party building website system based on SSH
- 20220718 安全帽、行人检测、数据集
- Dest0g3 520 orientation -web easyphp
- 机器人时代发展大趋势对民众的影响
- 2022.07.18 洛谷 P6722 「MCOI-01」Village 村庄
- 北京邮电大学|RIS辅助室内多机器人通信系统的联合深度强化学习
- Jincang database kingbasees SQL language reference manual (3.10. database object reference method)
- July 18, 2022, village of p6722 "mcoi-01" in Luogu
- Spire.Office For Net 7.7.2 以及新闻
- Session storage sessionstorage and local storage localstorage narrative and case analysis
猜你喜欢
The application could not be installed: INSTALL_FAILED_USER_RESTRICTED
马斯克称已将大脑上传到云端【系统或已开源】
迅为STM32MP157开发板安装VMware Tool工具
适应大众化教育的创客理念设计
Record the title of the 13th Landbridge cup embedded provincial competition
English grammar_ Possessive pronoun
stm32移植RT-Thread Nano实现finsh全步骤
[record of question brushing] 15 Sum of three numbers
Solution to the fourth weekly test of ACM intensive training of Hunan Institute of technology in 2022
实现统一账号登录,sonarqube集成ldap
随机推荐
BigDecimal使用不当,造成P0事故!
适合送礼的蓝牙耳机有哪些?2022蓝牙耳机排行榜10强
牛客多校第一场i题 Chiitoitsu 期望+概率DP
金仓数据库 KingbaseES SQL 语言参考手册 (3.10. 数据库对象引用方式)
Dest0g3 520迎新赛-web-EasyPHP
在公司解决的问题
Essays of this week (sorted out on weekends)
To do difficult work
解析创客教育课程设置中的创新思维
Using redis + Lua script to realize distributed flow restriction
Kingbasees SQL language reference manual of Jincang database (3.2. data type comparison rules)
会话存储sessionStorage与本地存储localStorage叙述与案例分析
Codeforces Round #807 (Div. 2) A-D
Microblogging system based on BS architecture
Sword finger offer 71: step jumping expansion problem
2022河南萌新联赛第(二)场:河南理工大学 B - 宝石
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
关于list循环这件事(foreach的五种写法)
基于BS架构的微博系统
赴港上市告吹后,土巴兔终止创业板IPO,创始人作出回应