JDBC interface technology (transfer)

xiaoxiao2021-03-06  64

JDBC is a JavaAPi (ApplicationProgrammingInterface application interface) that can perform SQL statements. It consists of a class and interface written by some Java language. JDBC provides database application developers, and database front desk tool developers provide a standard application design interface that allows developers to write complete database applications with pure Java languages. I. ODBC to JDBC's development history said JDBC, it is easy to think about another familiar word "ODBC". Is there any connection between them? If so, what is the relationship between them? ODBC is an English-English submissive of OpenDatabaseConnectivity. It is a standard application data interface that is implemented, standard application data interfaces, and standard application data interfaces that are used to disable data in associated or unrelated database management systems (DBMs). With ODBCAPI, the application can access data saved in a variety of different database management system (DBMS) regardless of the data storage format and programming interfaces for each DBMS. 1. ODBC's structural model ODBC structure includes four main parts: application interface, drive manager, database driver, and data source. Application Interface: The difference between the function call between the masked ODBC database driver provides a unified SQL programming interface for users. Drive Manager: Load the database driver for the application. Database driver: Implement ODBC function calls, providing SQL requests for a particular data source. If desired, the database drive will modify the application's request, so that the information supported by the relevant DBMS is requested. Data Source: The data you want to access and consist of the operating system, DBMS, and network platforms used to access DBMS. Although the primary purpose of the ODBC Drive Manager is to load the database driver so that the ODBC function calls, the database driver itself also performs an ODBC function call and cooperates with the database. Therefore, when the application system issues a call to the data source, the database driver can manage the communication protocol. When the connection to the data source is established, the database driver can handle the request to DBMS to DBMS, and the designs of the data source will be used to return to the application system. The following figure is the basic process of the ODBC program: 2. The birth of JDBC has been popular in Java since Java language officially announced in May 1995. A large number of programs written in Java language have also included database applications. Since there is no Java language API, the programmer has to add an ODBC function call to the C language in the Java program. This makes many good features of Java unable to give full, such as platform-independent, object-oriented characteristics. As more and more programmers have increasingly affected Java language, more and more companies are increasing in Java program development, and the requirements for accessing the database of Java language interfaces are getting stronger. Due to the deficiencies of ODBC, such as it is not easy to use, no object-oriented features, etc., Sun decided to develop a database application development interface for the interface. In JDK1. In the X version, JDBC is just an optional part. When the JDK1.1 is published, the SQL class (that is, JDBCAPI) has become the standard part of the Java language. Second, JDBC Technology Overview JDBC is a JavaAPi (ApplicationProgrammingInterface, application design interface) that can be used to perform SQL statements. It consists of a class written by some Java language. JDBC gives database application developers, database front desk tool developers provide a standard application design interface that enables developers to write complete database applications with pure Java language.

By using JDBC, developers can easily transmit SQL statements to almost any database. That is, developers can write to Sybase without writing a program, write another program to access Oracle, and write a program to access Microsoft's SQLServer. The program written by JDBC can automatically transfer the SQL statement to the corresponding database management system (DBMS). Not only this, applications written using Java can run on any support of Java, do not have to write different applications on different platforms. The combination of Java and JDBC allows developers to truly implement "Writeonce, Runeverywhere!" Java with robust, safe, easy-to-use features when developing database applications, and supports automatic online downloads, essentially a good database application Programming language. What it needs is how Java application is connected to a variety of databases, and JDBC is the key to implementing this connection. JDBC extends Java's ability. If you use Java and JDBCAPI, you can publish a web page, with a page with an APPLET that accesses the remote database. Or enterprises can connect all the employees through JDBC (they can use different operating systems such as Windwos, Machintosh and Unix) on the INTRANET on several global databases, and these global databases can be different. With more and more program developers use Java language, the need for Java access to database easily operability is getting stronger. MIS managers like Java and JDBC because it can be easily announced easily. Various transactions that have been installed in the database will continue to run normally, and even these transaction is stored in different database management systems; and the development time will be shortened, the installation and version upgrade will be greatly due to new database applications. simplify. Programmers can write or override a program, then place it on the server, and each user can access the server to get the latest version. For the information service industry, Java and JDBC provide a good way to update information to the outside user. 1. JDBC tasks simply, JDBC can complete the following three things: 1) The same database is established; 2) Send SQL statements to the database; 3) Process the result of the database returned. 2. JDBC-a bottom layer APIJDBC is a bottom API, which means it will call the SQL command directly. JDBC is completely competent, and it is more easier than other database interconnections. At the same time, it is also the basis for constructing high-level API and database development tools. High-level APIs and database development tools should be more friendly, more convenient, easier to understand. But all such APIs will eventually be translated into a bottom API like JDBC. At present, two JDBC-based high-level APIs are in the development phase. 1) The SQL language is embedded in Java's preprocessor. Although the DBMS has implemented SQL queries, JDBC requires SQL statements to be transmitted to the Java program as a string parameter. The embedded SQL preprocessor allows programmers to mix SQL statements: Java variables can be used in SQL statements to receive or provide a value. The SQL preparation will then translate the Java / SQL mixed program into Java programs with JDBCAPI. 2) Implement direct mapping from the relational database to the Java class. JavaSoft and other companies have announced this technology. In this "object / relationship" map, each line of the table will become an instance of such a class, each of which corresponds to an instance of an instance. Programmers can directly operate Java objects; and the SQL call required to access will be directly generated inside. It is also possible to achieve more complex mapping, such as multi-table rows implement in a Java class.

As you are constantly being strong for JDBC interest, more and more developers have begun to develop with JDBC-based tools. This makes it easy for development. At the same time, programmers are also developing applications that have access to databases for end users easier. 3. Comparison of JDBC and ODBC and other APIs so far, Microsoft's ODBC may be the API of the most extensive access to relational databases. It provides almost any platform, any ability of any database. So why not directly use ODBC directly from Java? The answer is that ODBC can be used from Java, but it is best to implement it with JDBC-ODBC bridge with the assistance of JDBC. So why do you need JDBC? To answer this question, there are such aspects: 1) ODBC is not suitable for direct use in Java. ODBC is an API implemented by a C language. Circular C procedures from Java programs will bring a series of shortcomings of security, integrity, and robustness. 2) Second, translation of ODBC written from C code ODBC to Javaapi is not satisfactory. For example, Java does not have a pointer, while a pointer is used in the ODBC, including very easy error-in-air pointers "void *". Therefore, for Java programmers, the JDBC is envisaged into an ODBC to object-oriented APIs is natural. 3) ODBC is not easy to learn, it is mixed with simple features and complex characteristics, even with a very simple query has complex options. JDBC is just the opposite, it maintains the simplicity of simple things, but the complex feature is allowed. 4) JavaApi such as JDBC is necessary for pure Java schemes. When using ODBC, people must install ODBC Drivers and Drive Manager on each client. If the JDBC drive is implemented in a Java language, then JDBC's code can be automatically downloaded and installed, and ensure its security, and this will adapt to any Java platform, from the network computer NC to large host mainframe. All in all, JDBCAPI is the most direct Java interface that can reflect SQL's most basic abstract concept. It constructs on the basis of ODBC, so familiar with ODBC's programmers will find that JDBC is very easy. JDBC maintains the basic design characteristics of ODBC. In fact, both interfaces are based on X / OpenSQL-based interface (CLI). Their maximum difference is that JDBC is based on Java-based style and advantages, and enhances Java's style and advantages. Recently, Microsoft introduced new APIs other than ODBC, such as RDO, ADO, and OLEDB. These APIs have tried to work together with JDBC in many ways, which is to become an object-oriented, ODBC-based interface. However, these interfaces do not currently replace ODBC, especially when the ODBC driver has formed in the market, it is more important that they are just ODBC's "beautiful packaging". 4. JDBC two-layer model and three-layer model JDBC support two-layer model, and also supports three-layer model access database. As shown in Figure 3, in the two-layer model, a Java Apple or a JA-VA application is directly connected to the database. This requires a JDBC driver that can be connected directly to the database being accessed. The user's SQL statement is transmitted to the database, and the results executed by these statements will be transmitted back to the user. The database can be connected to the same machine or on another machine. This is called a "client / server" structure, the user's computer is used as a client, and the computer running the database as a Server.

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

New Post(0)