JDBC stands for Java DataBase Connectivity ,  it is a standard Java API (Application Programming Interface)

for database-independent connectivity between the Java programming language and a wide range of databases.

The JDBC library includes several tasks commonly associated with database usage:

  • Making a connection to database
  • Creating SQL statements
  • Executing the SQL queries in the database
  • Viewing or Modifying the records

The Architecture of JDBC is as below :

JDBC Architecture

We use the JDBC API to control the JDBC Driver , then the JDBC Driver can help us to communicate with different kiinds of database system.

 We can download the jar file of JDBC for Mysql database from the url as below :

http://dev.mysql.com/downloads/mirror.php?id=404190#mirrors

 

There are following six steps involved in building a JDBC application:

  1. Import the packages . 

    Include the packages containing the JDBC classes needed for database programming. 

    Most often, using import java.sql.* will suffice.

  2. Register the JDBC driver . 

    Initialize a driver so you can open a communications channel with the database.

    Use Class.forName() to request the ClassLoader to load the driver to the environment of JVM.

  3. Open a connection . 

    Using the DriverManager.getConnection() method to create a Connection object, 

    which represents a physical connection with the database.

  4. Execute a query . 

    Building and submitting an SQL statement to the database.

  5. Extract data from result set . 

    Use the appropriateResultSet.getXXX() method to retrieve the data from the result set.

  6. Clean up the environment . 

    Closing all database resources versus relying on the JVM's garbage collection.

 

 

 

ref : http://www.tutorialspoint.com/jdbc/jdbc-introduction.htm

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JerryCheng 的頭像
    JerryCheng

    KwCheng's blog

    JerryCheng 發表在 痞客邦 留言(0) 人氣()