第一次写博客,希望各位大牛不要见笑。因为看了马士兵的视频,对JDBC有了初步的了解,故写成笔记以便以后进行回顾。
JDBC(java database connectivity,java数据库连接)是一种用于执行sql语句的java api。为了理解DBC,首先应该先了解sql语句,如最简单的六种基本sql语句:1、Select语句(最重要);2、Insert语句;3、Create语句;4、Delete语句;5、Update语句;6、Dropy语句
JDBC的编程模式很有规律,第一次接触可能会有点难以理解,但是一旦学会了,也就那么回事。一般有如下几个步骤:
1、Load the driver
a、Class.forName()|Class.forName().newInstance()|new DriverName()
b、实例化时自动向DriverManager注册,不需显式调用DriverManager.registerDriver方法
2、Connect to the DataBase
a、DriverManager.getConnection()
3、Execute the SQL
a、Connection.CreateStatement()
b、Statement.executeQuery()
c、Statement.executeUpdate()
4、Retrieve the result data
a、循环取得结果while(rs.next())
5、Show the reasult data
a、将数据库中的各种类型转换为java中的类型(getXXX)方法
6、Close
JDBC(java database connectivity,java数据库连接)是一种用于执行sql语句的java api。为了理解DBC,首先应该先了解sql语句,如最简单的六种基本sql语句:1、Select语句(最重要);2、Insert语句;3、Create语句;4、Delete语句;5、Update语句;6、Dropy语句
JDBC的编程模式很有规律,第一次接触可能会有点难以理解,但是一旦学会了,也就那么回事。一般有如下几个步骤:
1、Load the driver
a、Class.forName()|Class.forName().newInstance()|new DriverName()
b、实例化时自动向DriverManager注册,不需显式调用DriverManager.registerDriver方法
2、Connect to the DataBase
a、DriverManager.getConnection()
3、Execute the SQL
a、Connection.CreateStatement()
b、Statement.executeQuery()
c、Statement.executeUpdate()
4、Retrieve the result data
a、循环取得结果while(rs.next())
5、Show the reasult data
a、将数据库中的各种类型转换为java中的类型(getXXX)方法
6、Close
a、close the result. / close the statement / close the connection.
以上内容是从马士兵的视频中做的笔记,如有问题或者错误,请各位大牛指出,联系:229047554@qq.com