Code example for DataSource

Methods: getConnection

0
    } 
 
 
    public static Connection getConnection(DataSource ds) {
        try { 
            return ds.getConnection();
        } 
        catch (SQLException e) {
            throw new CannotGetConnectionException("Can not get connection from datasource", e);
        } 
    } 
 
 
    public static Object execute(Connection conn, ConnectionCallback connectionCallBack) {
        try { 
            if (connectionCallBack != null && conn != null) {
                return connectionCallBack.doInConnection(conn);
            } 
        } 
        catch (SQLException e) {
            log.error("doInConnection failed", e);