A complete database deployment architecture is typically composed of both client and server-side components. The client encapsulates the database request to send it to the server side, and the server side executes it and returns the result to the server side.
Take MySQL as an example
Describes Java application access to a database
JDBC Meaning: The application realizes access to any database by invoking the unified interface, which masks the implementation details of the client-server interaction protocol.
For Java, JDBC is a class library, and for databases, JDBC is the interface specification.
With JDBC, the application becomes simpler, improves the efficiency of program development, makes the Java Web cross-platform for different databases, and based on JDBC, we can develop more powerful frameworks.
JDBC Architecture diagram
JDBC is divided into two tiers from the architecture:
Upper API: Communicating with the Java Web program we write
Downlevel Database drivers: Connect to specific databases, typically provided by individual database vendors
Before using JDBC, we prepare a back-end instance of the MySQL database, and the Java application implements the read person name
Several important Java classes are involved in the JDBC API:
1.Driver &drivermanager
Driver is actually an interface that defines the functions that each driver must implement and is the abstraction of the driver. By manipulating the driver interface, you can implement operations on individual drivers.
DriverManager is the management class of driver, By Class.forName, the user registers a driver with DriverManager and then drivermanager through the Getconnection method, invokes the driver, and establishes a physical link to the backend database.
The Connection object represents a physical link to the back-end database for a Java application.
Connection object creates one or more statement objects
Statement object: Is a SQL container that holds SQL statements, performs update query delete operations,
Execute a database query with the ExecuteQuery method of the statement object to get a collection of database query results, represented by a ResultSet object.
By deleting and updating the Execute and EXECUTEUPDATE statements of the statement object, the object that returns an int value represents the number of database records that the operation affects.
introduce the ResultSet object :
Represents the result of the SQL query, the relational database is essentially a two-dollar table, and the ResultSet object is actually a two-dollar table of rows and columns.
Is the next line, the previous line, to a row, before the first row, after the last row
Adjust to the row after the corresponding to the column:
Column or column ordinal (sorted from 0)
An exception may be thrown during the operation, SqlException processing
Getconnection (Db_url,uder,pass) has three parameters.
Java Web Database Development 1