Database connectivity is a critical, limited and expensive resource, especially in multi-user Web applications. The management of database connections can significantly affect the scalability and robustness of the entire application, Affects the performance metrics of the program. The database connection pool is formally addressed to this issue. The database connection
binding of objects and names,And the method of querying objects by name lookup ().DataSource DS= (DataSource) ctx.lookup ("java:comp/env/jdbc/calculation"); Conn=ds.getconnection (); stmt=conn.createstatement (); String SQL="INSERT into Biaodashi values ('"+result+"')"; Stmt.execute (SQL); Stmt.close (); Conn.close (); } Catch(Exception e) {System. out. println (e); }Here are the
Tags: new pwd final static code block. exe back one upd else Custom connection Pooling one:
The 1.sun provides a connection pool interface Javax.sql.DataSource.
2. Define the connection pool myDataSource Implement Interface DataSource.
3. Using the collection Lin
release the connection for the specified time.** @param name Connection pool name* @param time to wait in milliseconds* @return Connection available connection or null*/Public Connection getconnection (String name, long time){Dbc
TuningProvide the basis.
2. Connection Pool provided by the server
The jdbc api does not provide the connection pool method. Some large web application servers such as BEA's WebLogic and IBM WebSphere provide connection
provide the basis for system development test and performance adjustment.
2, the server from the connection pool with
There is no method in the JDBC API to provide connection pooling. Some large Web application servers, such as Bea's WebLogic and IBM's WebSphere, provide a mechanism for
December 05, 2002
The
author implements the database connection pool by using dynamic proxies in Java, allowing the consumer to use the connection pool in a normal JDBC connection
Tags: sharding first come ROM features tor mid-large number usage performance improvementMainstream database connection poolCommon open source database connection pools are c3p0, DBCP, Tomcat Jdbc pool, BONECP, druid, etc.C3P0: Open source JDBC
information of JDBC directly after creating the object, such as: Database driver, database URL, login database user name and password, and then manipulate the database. - * Mode two: Build an XML or properties configuration file, there is no need to set the basic information of the database when the configuration file exists. Direct access to database connections, corresponding operations to the database - */
- Public classC3P0 { + Public Sta
first is to understand the configuration of the connection pool (above)The second is to know the wait_timeout settings in MySQLTwo-point combination to determine the proper configuration of the connection pool in the project.If Wait_timeout is set to a large value, such as a year, the configuration above is correct in
Using Tomcat's JDBC Connection pool in the project, the problem was that when the database was restarted, the service did not reconnect to the database and needed to restart the deployed project to connect to the database. After testing the configuration to make a change:Add two configuration attributes where DataSource is configured: name= "Testonborrow"
= "111111" driverclassname= "Com.mysql.jdbc.Driver"Url= "Jdbc:mysql://localhost:3306/testdb"/>The meanings of the attributes in the resource tag in the configuration file:The full name of the database-driven class used by the DRIVERCLASSNAME-JDBC.Maxactive-The maximum number of active connections that the connection pool provides at the same time.Maxidle-The maximum number of connections that the
consume resources, but they cannot be too large, because when the machine is idle, it will also create connections smaller than the number of minidle, similar to the Xmn setting in jvm parameters)5. maxWait: maximum wait time. When no connection is available, the maximum wait time for the connection pool to wait for the conn
JDBC Connection Database• Create a program that connects to the database in JDBC with 7 steps:1. Load the JDBC driver:Before connecting to the database, first load the driver of the database you want to connect to the JVM (Java Virtual machine),This is achieved through the s
Used to write their own database connection pool, has not been garbled problem.Because I heard that the tomcat7 of the connection pool efficiency is good, want to use, the result has been garbled.Garbled production path is just a few, MySQL build library and build the table when the specified code, Eclipse Engineering
Open source database connection pools in Java are available in the following ways:1, c3p0 c3p0 is an open source JDBC connection pool that is published in the Lib directory with Hibernate, including connection and statement to imp
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.