JDBC核心API

JDBC核心API在java.sql.*和javax.sql。*

1、Driver接口:表示Java驱动程序接口,具体的数据库厂商要实现其此接口

  connect(url、propertis):连接数据库的方法

    url:连接数据库的URL

      url语法格式:jdbc协议:数据库子协议://主机:端口/数据库

      user:数据库用户名

      password:数据库用户密码

2、DriverManager类:驱动管理器的类,管理所有的注册驱动程序

  registerDriver(driver):注册驱动

  Connection getConnection(url,user,password):获取连接对象

3、Connection 接口:表示java程序和数据库的连接对象

  Statement createStatement():

  PreparedStatement prepareStatement() 

  CallableStatement prepareCall(String sql)

 3.1、Statement接口:用于执行静态SQL语句

  int executeUpdate(String sql) :执行静态的更新SQL语句(DDL、DML)

  ResultSet executeQuery(String sql) :执行静态查询的SQL语句(DQL)

 3.2、PreparedStatement接口:(是Statement的子类)

  int executeUpdate():执行预编译SQL语句对象(DDL、DML)

  ResultSet executeQuery():执行预编译查询SQL语句(DQL)

 3.3、CallableStatement接口:用于执行存储过程的SQL语句

  ResultSet executeQuery():调用存储过程的方法

4、ResultSet接口用于封装查询出来的数据

  boolean next():将光标移动到下一行。

  getXX():获取列的值。

原文地址:https://www.cnblogs.com/StanLong/p/6892152.html