20th. Database Operations----JDBC Overview

Source: Internet
Author: User
Tags odbc

JDBC is a Java API (application programming Interface, Application design interface) that can be used to execute SQL statements and is a link between a database and a Java application.

1. Jdbc-odbc Bridge

The Jdbc-odbc Bridge is a JDBC driver that completes the transition from JDBC operations to ODBC operations, allowing the JDBC driver to be used as a driver for ODBC. The steps to connect to the database using the Jdbc-odbc bridge are as follows:

(1) First load the Jdbc-odbc bridge driver, the code is as follows:

Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");

Description: Class is a class in the Java.lang package that forname () loads the Jdbcodbcdriver class in the SUN.JDBC.ODBC package to establish a JDBC-ODBC bridge connector by using the class's static method.

(2) Using the connection interface in the java.sql package and creating a connection object through the static method of the DriverManager class getconnection (), the code is as follows:

Connection conn=drivermanager.getconnection ("JDBC:ODBC: Data Source name", "User name", "password");

Description: The data source must give a short descriptive name. If you do not set the user name and password, you want to exchange data with the data source Tom. The code is as follows:

Connection conn=drivermanager.getconnection ("Jdbc.odbc:tom", "", "" ");

(3) Send SQL statements to the database. Declare an SQL statement object using the statement interface and create the SQL object from the connection database object Conn createstatement () method you just created, with the following code:

Statement sql=conn.createstatement ();

Jdbc-odbc Bridge as a bridging technology for connecting databases. Now it is not widely used in Java, it is now widely used in JDBC technology. The Jdbc-odbc bridge is automatically installed as a SUN.JDBC.ODBC package with the JDK and does not require special configuration.

2. JDBC Technology

JDBC (Java Database connectiviry) is a set of object-oriented application interfaces that specify a unified standard interface for accessing various relational databases. JDBC is an underlying API, so you need to embed SQL statements in the business logic layer when accessing the database. JDBC does not have direct access to the database and must rely on the JDBC driver provided by the database vendor.

  The overall structure of JDBC consists of 4 components----applications, driver managers, drivers, and data sources.                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                     &NBSp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                 &NBsp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                

20th. Database Operations----JDBC Overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.