All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.tangjiabao.halodb.dbutils.DbUtilsEx Maven / Gradle / Ivy

Go to download

Orm whitch The highest development efficiency and Efficiency is the fastest

There is a newer version: 0.17
Show newest version
package cn.tangjiabao.halodb.dbutils;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import cn.tangjiabao.halodb.core.exception.CannotGetConnectionException;

/**
 *DbUtils扩展组件
 * @author [email protected]
 * @date 2015-6-14 下午10:27:24
 */
public class DbUtilsEx{
    private  static  Connection  preConnection(DataSource dataSource) throws SQLException{
        if (null==dataSource) {
            throw new SQLException(
                    "QueryRunner requires a DataSource to be "
                            + "invoked in this way, or a Connection should be passed in");
        }
    	return dataSource.getConnection();
    }
    public static Connection  getConnection(DataSource dataSource) throws CannotGetConnectionException{
    	Connection conn= null;
    	try {
    		conn=preConnection(dataSource);
		} catch (SQLException ex) {
			throw new CannotGetConnectionException("Could not get JDBC Connection", ex);
		}
		return conn;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy