Research and Application of JDBC-based database connection pool technology

Source: Internet
Author: User

Introduction

In recent years, with the rapid development of Internet/Intranet network construction technology and the rapid popularization in the world

Applications have been switched from traditional desktop applications to Web applications. The layer-3 development mode based on the Browser/Server architecture gradually replaces the development mode of the C/S (Client/Server) architecture, it has become a widely used technology for developing enterprise-level applications and e-commerce. In the early days of Web application development, the main technologies used were CGI, ASP, and PHP. Later, Sun introduced Servlet + jsp based on Java language (preferred for SUN Enterprise Applications) + JavaBean technology. Compared with traditional development technologies, it features cross-platform, secure, effective, and portable features, making it easier to use and develop.

How Java applications access the database

In Java, JDBC (Java DataBase Connection) serves as a bridge between applications and databases,

That is, the Java language accesses the database through the JDBC technology. JDBC is an open solution that provides a standard application design interface for database application developers and Database Front-End Tool developers, this allows developers to write complete database applications in pure Java. JDBC provides two types of APIS, namely for developers and for the underlying JDBC driver API, the underlying mainly through direct JDBC driver and JDBC-ODBC bridge driver to achieve the connection with the database.

Generally, the Java application accesses the database (1) as follows:

① Load the database driver;

② Establish a database connection through JDBC;

③ Access the database and execute SQL statements;

④ Disconnect the database.


Figure 1 Java Database Access Mechanism JDBC, as a database access technology, has the advantages of simplicity and ease of use. However, using this mode for Web application development has many problems: first, each Web request requires a database connection. Establishing a connection is a time-consuming activity, and it takes seconds each time ~ 1 S, and the system also needs to allocate memory resources. This time may not feel the system overhead for one or several database operations. However, for today's Web applications, especially large e-commerce websites, it is normal that hundreds or even thousands of people are online at the same time. In this case, frequent database connection operations will inevitably occupy a lot of system resources, and the website's response speed will inevitably decrease, which may even cause server crashes. This is a technical bottleneck restricting the development of some e-commerce websites. Second, each database connection must be closed after use. Otherwise, if the program fails to be closed due to an exception, the memory in the database system may leak and the database will have to be restarted. In addition, such development cannot control the number of connection objects to be created, and system resources will be allocated out without consideration. For example, too many connections may also cause memory leakage and server crash. How database connection pool Works 1. Basic Concepts and Principles

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.