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