JDBC初步
来源:互联网 发布:android获取mac地址 编辑:程序博客网 时间:2024/06/03 20:37
Java Data Base Connectivity
JDBC编程步骤:
1.Load the Driver
Class.forName() | Class.forName().newInstance() | new DriverName()
2.Connect to Database
DriverManager.getConnection()
3.Execute SQL
Connection.createStatement();
Statement.executeQuery(); //查询
Statement.executeUpdate(); //增、删、改
4.Retrieve the result data
循环取得结果 while(ResultSet.next())
5.Show result data
将数据库中的各种类型转换为Java中的类型
6.Close
close ResultSet / close Statement /close Connection
示例:
import java.sql.*;public class example {public void getConnection() throws Exception{Class.forName("com.mysql.jdbc.Driver");Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbc","root","root");Statement stmt = conn.createStatement();String sql = "select * from TableName";ResultSet rs = stmt.executeQuery(sql);while(rs.next()){String name = rs.getString(1);}rs.close();stmt.close();conn.close();}}
0 0
- JDBC 初步
- JDBC 初步
- JDBC初步
- JDBC初步
- JDBC初步
- JDBC初步
- Java JDBC初步
- JDBC初步使用
- jdbc初步(转)
- JDBC 初步笔记1
- JDBC 初步笔记2
- JDBC的初步
- 初步封装jdbc
- 初步理解JDBC
- JDBC的初步使用
- JDBC初步学习
- jdbc初步学习(一)
- JDBC(MYSQL)初步学习
- 为什么要开发NFianl框架
- #leetcode#Majority Element II
- sql求时间差
- 安装apk提示Install_failed_invalid_UR解决办法
- 织梦dede二级栏目如何调用?
- JDBC初步
- 从Unreal Engine 3到Unreal Engine 4
- 破解一个IPHONE小游戏魔幻塔防,从小的开始学习反编译。
- tableViewCell的网络图片加载方法
- easy ui tree 默认选中指定行
- Html文档服务Resin3.0.24 文件读写Bug
- 动物不锈钢雕塑价格-曲阳不锈钢雕塑生产厂-曲阳县金铭雕塑品有限公司
- IOS开发快捷键整理
- STL中的二分查找--lower_bound/upper_bound/binary_search