JDBC URL

xiaoxiao2021-03-06  55

1. JDBC URL concept

The JDBC URL provides a method of identifying a database that enables the corresponding driver to identify the database and establish a connection thereto. In fact, the driver programmer will determine what JDBC URL identifies a particular driver. Users don't have to care about how to form a JDBC URL, they only need to use the URL provided with the drivers used. JDBC's role is to provide some conventions, and the driver programmer should follow these conventions when constructing their JDBC URL.

(1) Since the JDBC URL should be used with a variety of different drivers, these conventions should be very flexible. First, they should allow different drivers to use different scenarios to name the database. For example, an ODBC sub protocol allows (but not required) URLs contain attribute values.

(2) The JDBC URL should allow the driver programmer to be encapsulated in it. This allows you to open the database connection with the applet of the database dialog, without requiring users to do any system management.

(3) The JDBC URL should allow some degree of indirectness. That is, the JDBC URL can point to the logical host or database name, and this logical host or database name will dynamically convert to the actual name by the network naming system. This allows the system to declare a particular host as part of the JDBC name. Network naming services (such as: DNS, NIS, and DCE) have multiple, and no restrictions on which naming service used.

2.JDBC URL format

The standard syntax of the JDBC URL is as follows. It consists of three parts, and each part is separated by colon.

JDBC: :

The three parts of the JDBC URL can be decomposed as follows:

(1) JDBC - protocol. The protocol in the JDBC URL is always JDBC.

(2) - Driven name or database connection mechanism (this mechanism can be supported by one or more drivers). The typical example of the sub-protocol name is: ODBC, which is specifically reserved for the URL for specifying the data resource name of the ODBC style. For example, in order to access a database through a JDBC-ODBC bridge, you can use the following UR:

JDBC: ODBC: MyDatabase

(3) - A method of identifying a database. The child name can vary depending on the sub-protocol, the purpose of the sub-name is to provide sufficient information for positioning the database. If the database is accessed via the Internet, the network address is included in the JDBC URL into part of the sub-name, and must follow the standard URL naming convention as shown below:

/ / Host Name: Port / Sub Agreement

转载请注明原文地址:https://www.9cbs.com/read-114805.html

New Post(0)