Java connection pool technology
How to Use JNDI (Java Naming and Directory Interface) is an application Interface that provides developers with a universal and unified Interface for searching and accessing various Naming and Directory services, JDBC is built on the abstracti
Java framework --- hibernate connection pool, java --- hibernate
Hibernate supports third-party connection pools. the officially recommended connection pools are C3P0, Proxool, and DBCP. Note the following three points when config
Tags: database connection pool DBCP c3p0 Javac3p0 is an open source JDBC Connection pool that implements the data source and Jndi bindings to support the standard extensions of the JDBC3 specification and JDBC2. The open source projects that currently use it are hibernate,sp
Basic Principles of database connection pool technology:
A data source object is provided by a Web Container (such as Tomcat ).ProgramUsing the JNDI technology to obtain this object. Generally, If you create a connection by yourself, use the followingCodeGet the data source object:
Context context = new initialcontext ();
Datasource = (datasource) Context.
C3P0 is an open source JDBC Connection pool that is published with Hibernate in the Lib directory and includes connection objects that implement the statement and datasources pools for JDBC3 and JDBC2 extension specifications.
BONECP is an open-source, fast JDBC
to the manager, thus minimizing unnecessary database connection consumption.The Java Database service JDBC does not provide an actual connectionpool implementation, but leaves out an interface to support a third-party service provider, and I think the most important interface is datasource.There are actually four ways that J
Use JNDI access to connection pools for data sources, Java messaging services, mail sessions, and URL connections
Understanding JNDI
JNDI is an application programming interface (API) or library that provides an application with methods to associate names with objects and to find objects in the directory based on the name of the object. This article is the first part of a series of tutorials that will giv
driver package introduced in the demo, which includes the oracleconnectionpooldatasource class that implements the database connection pool., You need to go to the Oracle website to download according to your own database version (click to open the link ). The Code is as follows:
Pooldbsource class
Package COM. ***. connectionpool. DB; import Java. SQL.
.2 JDBC Database connection pool interface (DataSource)Java provides a common interface for database connection pooling: Javax.sql.DataSource, each vendor can have its own connection pool
a username and password
-Ct=drivermanager.getconnection ("Jdbc:odbc:mytest"); the
- //3. Create statement or preparedstatement[differences]
-Sm=ct.createstatement ();//statement use: used primarily to send SQL statements to a database -
+ //4. Execute (crud, create DATABASE, back up database, delete data ...) - //Demo Adds a piece of data to the course table, executeupdate can perform add delete and modify operations
+
BONECP is a fast, free, Open-source, Java database connection pool (JDBC pool) library. If you are are familiar with C3P0 and DBCP then your already know what this means. For the rest, this is a library of that would manage a database co
() {return This.testta
ble /** * * Set the name of the test table * * @param testtable * String Test table name/public void settesttable (String te
sttable) { this.testtable = testtable; /** * Create a database connection pool, the number of available connections in the connection pool is the value set in class m
If you encounter the exception prompt in the client tool such as Dbeaver:At this point, you need to log in to the server and set up your MySQL and restart MySQL as follows
Vim/etc/mysql/my.cnf
Configure the bind-address inside = 127.0.0.1
This one changed to Bind-address = 0.0.0.0Cancel MySQL Server binding to the address!Save exit after (Wq)2.sudo/etc/init.d/mysql Restart (restart MySQL service)If the following error also occurs:Execute the following command in the server's MySQL dat
First, the introduction
Pooling technology is widely used in Java, in the case of Jane, the object pool is used to store an instance with a limited number of instances, the developer takes an instance from the object pool, and then changes back to the object pool, thereby reducing the overhead of the system frequently
idle time of a connectionM_MaxConnections =-1: Maximum number of connections at the same timeM_timer: TimerThese attributes define the valid status values of the connection pool and each connection in it. The self-management of the connection pool is to determine the status
connection.preparestatement (), Statement.execute (), statement.close ().
1 VERSIONS:HIKARICP 2.1.0, BONECP 0.8.0, Tomcat 8.0.9, Vibur 1.2.0, c3p0 0.9.5-pre8, Java 8u202 Java Options:-server-xx:+aggressiveopts-xx:+usefastaccessormethods-xmx512mLook at the comparison chart given from the HIKARICP website. Its performance compared to the BONECP has a qualitative change, a revolutionary change.I am using t
;
Import Java.sql.DriverManager;
Import Java.sql.ResultSet;
Import java.sql.SQLException;
Import java.sql.Statement; /** * in threadlocal package connection * * @author Administrator * * * * public class ConnectionManager {private static Th
readlocal Add: Oracle The connection: DriverClass:oracle.jdbc.driver.OracleDriver
Url:jdbc:oracle:thin: @localhost: 1521:ORCL Summary But is it a hassle t
(); String sql ="SELECT count (ID) from user";//Call the ExecuteQuery () method to perform a query operation that returns a resultset result set that contains the results of the queryrs = stmt.executequery (SQL);//4. Manipulating ResultSet result sets intCount=0;if(Rs.next ()) {//Move the pointer forward one line to determine if there is a recordCount=rs.getint (1); } System.out.println ("Total"+count+"a user!" "); }Catch(ClassNotFoundException e) {E.printstacktrace (); }Catch
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.