org.darkphoenixs.pool.jdbc.JdbcConnectionPool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of connectionpool-client Show documentation
Show all versions of connectionpool-client Show documentation
A simple multi-purpose connection pool client (Kafka & Hbase & Redis & RMDB & Socket & Http)
The newest version!
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.jdbc;
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolBase;
import org.darkphoenixs.pool.PoolConfig;
import java.sql.Connection;
import java.util.Properties;
/**
* Title: JdbcConnectionPool
* Description: Jdbc连接池
*
* @author Victor.Zxy
* @version 1.0
* @see PoolBase
* @see ConnectionPool
* @since 2015年11月17日
*/
public class JdbcConnectionPool extends PoolBase implements ConnectionPool {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 2743612676107943708L;
/**
* Title: JdbcConnectionPool
* Description: 默认构造方法
*/
public JdbcConnectionPool() {
this(JdbcConfig.DEFAULT_DRIVER_CLASS, JdbcConfig.DEFAULT_JDBC_URL, JdbcConfig.DEFAULT_JDBC_USERNAME, JdbcConfig.DEFAULT_JDBC_PASSWORD);
}
/**
* Title: JdbcConnectionPool
* Description: 构造方法
*
* @param properties JDBC参数
*/
public JdbcConnectionPool(final Properties properties) {
this(new PoolConfig(), properties);
}
/**
* Title: JdbcConnectionPool
* Description: 构造方法
*
* @param driverClass 驱动类
* @param jdbcUrl 数据库URL
* @param username 数据库用户名
* @param password 数据密码
*/
public JdbcConnectionPool(final String driverClass, final String jdbcUrl, final String username, final String password) {
this(new PoolConfig(), driverClass, jdbcUrl, username, password);
}
/**
* Title: JdbcConnectionPool
* Description: 构造方法
*
* @param poolConfig 池配置
* @param properties JDBC参数
*/
public JdbcConnectionPool(final PoolConfig poolConfig, final Properties properties) {
super(poolConfig, new JdbcConnectionFactory(properties));
}
/**
* Title: JdbcConnectionPool
* Description: 构造方法
*
* @param poolConfig 池配置
* @param driverClass 驱动类
* @param jdbcUrl 数据库URL
* @param username 数据库用户名
* @param password 数据密码
*/
public JdbcConnectionPool(final PoolConfig poolConfig, final String driverClass, final String jdbcUrl, final String username, final String password) {
super(poolConfig, new JdbcConnectionFactory(driverClass, jdbcUrl, username, password));
}
@Override
public Connection getConnection() {
return super.getResource();
}
@Override
public void returnConnection(Connection conn) {
super.returnResource(conn);
}
@Override
public void invalidateConnection(Connection conn) {
super.invalidateResource(conn);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy