Comprehensive analysis JDBC (9)

  Comprehensive analysis JDBC (9) 

  Appendix: JDBC TM Technical Analysis 

  1. JDBCTM definition 

  JDBCTM is a SQL statement for the implementation of the JavaTM JavaTM API, which comprises a group of the Java programming language with the preparation of the class and interface components.    JDBC for tools / database development provides a standard API, so that they can be used to prepare pure Java API database applications. 

  With JDBC, sent to various relational database SQL statement is a very easy matter.    In other words, a JDBC API, we do not have to visit a Sybase database to write specialized procedures, visit the Oracle database to write a program specifically for the visit Informix database and write another program, and so on.    JDBC API you can use to write a program it can be enough to send the corresponding database SQL statements.    Moreover, the use of the Java programming language prepared by the application, need not to worry to prepare for the different platforms of different applications.    Will be combined with Java and JDBC programmers will once again need only write it in a program running on any platform. 

  Java with a solid, safe, easy to use, easy to understand and can be automatically downloaded from the Internet and other characteristics of the preparation of the outstanding database application language.    Need is a Java application with a variety of different databases for dialogue between the methods.    The JDBC is the mechanism for such purposes. 

  Java JDBC expanded functionality.    For example, with Java and JDBC API can be issued containing Applet website, and the applet may use the information from remote databases enterprises can also use JDBC to all staff through the Intranet will be connected to one or more of the internal database (even if those used by staff computer had Windows, Macintosh, and UNIX, and other various operating systems).    With an increasing number of programmers using the Java programming language, Java from the convenient access to the database requirements are increasing. 

  MIS administrators like the combination of Java and JDBC, because it makes it easy to disseminate information and the economy.    Enterprises can continue to use their installed database, and can easily access information, even if this information is stored in the different database management systems.    The development of new procedures for a very short period.    Installation and version control will be greatly simplified.    Programmers can prepare only what applications or updated only once, and then put it on the server, and then on any person can get the latest version of the application.    Sales for the business information services, Java and JDBC for external customers with better access to information update method. 

  2. Uses JDBC 

  Simply put, JDBC to do three things: establish a connection with the database, send SQL statements and the results.    The following code of the above steps are the basic examples: 

  Connection con = DriverManager.getConnection ( "jdbc: odbc: wombat," "login" 
  "Password"); 
  Statement stmt = con.createStatement (); 
  ResultSet rs = stmt.executeQuery ( "SELECT a, b, c FROM Table1"); 
  While (rs.next ()) ( 
  Int x = rs.getInt ( "a"); 
  String s = rs.getString ( "b"); 
  Float f = rs.getFloat ( "c"); 
  ) 

  Based on the above code JDBC database access to a summary of the classic, of course, in this part of the follow-up section will do a detailed analysis of it on. 

  3. JDBC API 

  JDBC is a "low-level" interface, that is, it calls for direct SQL commands.    In this respect it functions very good, and other than the easy-to-use database connectivity API, but it also is designed as a base interface, it can be established on the High interface and tools.    High interface is "user-friendly" interface, which uses a more comprehensible and more convenient API, in the shadow of this API is converted to such a low level, such as JDBC interface. 

  In the relational database "object / relationship" mapping, each row in the table corresponds to a category of examples, and each column values corresponding to the example of an attribute.    Therefore, programmers can directly operate on the Java objects; SQL for data access call will be "under the guise of" automatically generated.    In addition also provides more complex mapping, for example, a number of rows in the table integrated into a Java class. 

  With the interest of the people of JDBC the growing, and more and more developers have been using JDBC-based tools to enable the preparation of procedures easier.    Programmers has been trying to make in the preparation of end-user database access has become more simple applications.    For example, applications can provide a choice of menu database tasks.    Task was chosen, the application will be given tips and blank selected for the task of completing the implementation of the necessary information.    Application procedures for the importation of the required information will automatically call for SQL commands.    In such a process with the assistance, even if they do not understand the fundamental SQL syntax, but also can perform database tasks. 

  4. JDBC and ODBC API and other Comparison 

  Currently, Microsoft's ODBC API is the most widely used for the visit of the relational database programming interface.    It can connect almost all platforms almost all databases.    Why not use ODBC Java?    The answer to this question is: Java can use ODBC, but preferably with the help of the JDBC to JDBC-ODBC Bridge in the form of use, which we later say.    The problem now has become: "Why do we need JDBC?"    The answer is clear: ODBC not suitable for direct use in Java, because it uses C language interface.    Java call from the C code in the local security, achieved solid and procedural aspects of the automatic transplantation has many shortcomings.    From ODBC C API Java API to the literal translation is not advisable.    For example, Java does not guide, and it has ODBC indicators used very widely (including very error-prone Guidelines "void *").    You can imagine JDBC will be converted into the object-oriented interface to the ODBC, and object-oriented interface to make it easier for Java programmers to receive. 

  ODBC difficult to learn.    It simple and advanced features of the mix, and even the simple query, the options are extremely complex.    On the contrary, JDBC to guarantee simple function of simplicity, and at the same time, if necessary, to allow the use of advanced features.    The opening of "pure Java" mechanism needs such as JDBC Java API.    If you use ODBC, it is necessary to manually will be ODBC driver management and driver installation in each client machines.    If completely written in Java JDBC Driver in all the JDBC code on the Java platform (from the computer network to the mainframe) can be automatically installed, and guarantee the safety of transplantation. 

  In short, JDBC API for SQL abstract and basic concepts of Java is a natural interface.    It is built on ODBC rather than starting from scratch.    Therefore, programmers will be familiar with the ODBC JDBC found very easy to use.    ODBC JDBC retain the basic design features; In fact, the two interfaces are based on the X / Open SQL CLI (call-level interface).    The biggest difference between them is: Java JDBC to style and based on the merits and optimization, more easy to use. 

  At present, Microsoft has introduced a new addition to ODBC API: RDO, ADO and OLE DB.    These design in many ways and JDBC is the same, that is, they are the object-oriented database interface and can be based on achieving the ODBC category.    But the interface, we did not see any special features that make their choice we need to turn to alternative ODBC, especially in the ODBC driver has already established a more perfect market conditions.    They also is the largest in the ODBC add a decoration only. 

  5. JDBC on the B / S and C / S mode support 

  JDBC API supports both the two-tier model of database access (C / S), but has also supported the three-tier model (B / S).    In the two-tier model, Java applet or application will be a dialogue directly with the database.    This will require a JDBC driver to visit with the specific database management systems to communicate.    Users of SQL statements sent to the database, and its results will be returned to customers.    Database can be located on another computer, users connected to the above network.    This is called client / server configuration, user's computer for the client, providing computers for database servers.    Intranet network can be (it can be linked to company staff), it can also be a Internet. 

  In the three-tier model, the order was first sent to the "middle layer", and then by the SQL statement it sent to the database.    Database on SQL statement processed and the results sent back to the middle layer, then the results returned to the middle layer to the user.    MIS managers have discovered the three-tier model is very attractive, because the middle layer can be used to control access to company data and can be used for the newer types.    Another advantage of the middle layer, the user can use the easy-to-use high-level API, and the middle layer will be converted to its corresponding low-level calls.    Finally, in many cases under the three-tier structure can provide some performance benefits. 

  So far, the middle layer are usually in C or C + + language to prepare such, the implementation of these languages faster.    However, with the most optimized compiler (it to Java byte code for the efficient conversion of specific machine code) the introduction, use Java to achieve middle layer will be more practical.    This will be a big step forward, it enables people to take full advantage of Java's many advantages (such as robust, multi-threaded, and security features).    For Java JDBC from the middle layer to access a database is very important. 

  6. SQL consistency 

  Structured Query Language (SQL) relational database access is the standard language.    The tricky part is: Although most of the DBMS (database management system) use their basic function of the standard form of SQL, but they are not consistent with the recent higher standard definition of the functions of SQL syntax or semantics.    For example, not all databases support stored procedures or external connections, those who support this function in the database and mutually inconsistent.    It is hoped that the SQL standard that the real part to expanding to include more and more functions.    But at the same time JDBC API must support the existing SQL. 

  JDBC API solution to this problem is to allow a way for any string has been reached by the driver on the DBMS.    This means that applications can use any number of SQL functions, but it must take the risk: it is possible in some DBMS errors.    In fact, applications for SQL even if not, or that it may be for a specific SQL DBMS design special allocation of (for example, documents or images enquiries). 

  JDBC deal with the issue of consistency SQL second method is to provide ODBC-style escape clause, which would in part in the follow-up discussion.    Escape for a few common grammatical differences SQL provides a standard syntax JDBC.    For example, the date has been stored text and the process of calling all escaped grammar. 

  For complex applications, JDBC third method used to deal with the issue of consistency in its SQL DatabaseMetaData interface to use DBMS on the description of information, so that each application can adapt to the requirements and functional DBMS. 

  As JDBC API will be used to develop advanced tools and database access API API basis, it must also pay attention to the consistency of all its superstructure.    "TM with JDBC standards," representatives of the JDBC users can rely on the standard-level functions.    To use this statement, the driver must be at least support the ANSI SQL-2 Entry Level (ANSI SQL-2 represent the United States National Bureau of Standards in 1992, the standards adopted. Entry Level SQL functions on behalf of a specific list).    Driver JDBC API developers can be carried by the test kit to determine whether the driver of their compliance with these standards. 

  "TM with JDBC standards," said the JDBC providers have been adopted to achieve the JavaSoft provide conformance tests.    These tests will check the consistency of the definition of JDBC API all the classes and methods exist, as far as possible, to check whether the procedures SQL Entry Level function.    Of course, these tests is not entirely, but now has no intention of JavaSoft the various providers to the realization of superscript level.    However, this definition of consistency can indeed achieve the JDBC provide a certain degree of credibility.    As more and more database providers, linking providers, Internet providers and application programming Members of the JDBC API acceptance, JDBC is also rapidly becoming the standard Java database access. 

  (End). 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Recommend Articles

Comments

Leave a Reply