Example usage for org.apache.ibatis.datasource.pooled PooledDataSource setPoolMaximumCheckoutTime

List of usage examples for org.apache.ibatis.datasource.pooled PooledDataSource setPoolMaximumCheckoutTime

Introduction

In this page you can find the example usage for org.apache.ibatis.datasource.pooled PooledDataSource setPoolMaximumCheckoutTime.

Prototype

public void setPoolMaximumCheckoutTime(int poolMaximumCheckoutTime) 

Source Link

Document

The maximum time a connection can be used before it *may* be given away again.

Usage

From source file:com.raise.orgs.impl.cfg.ProcessEngineConfigurationImpl.java

License:Apache License

protected void initDataSource() {
    if (dataSource == null) {
        if (dataSourceJndiName != null) {
            try {
                dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
            } catch (Exception e) {
                throw new ActivitiException(
                        "couldn't lookup datasource from " + dataSourceJndiName + ": " + e.getMessage(), e);
            }//from  w w  w.j a v  a  2 s . c om

        } else if (jdbcUrl != null) {
            if ((jdbcDriver == null) || (jdbcUrl == null) || (jdbcUsername == null)) {
                throw new ActivitiException(
                        "DataSource or JDBC properties have to be specified in a process engine configuration");
            }

            log.debug("initializing datasource to db: {}", jdbcUrl);

            PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver,
                    jdbcUrl, jdbcUsername, jdbcPassword);

            if (jdbcMaxActiveConnections > 0) {
                pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
            }
            if (jdbcMaxIdleConnections > 0) {
                pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
            }
            if (jdbcMaxCheckoutTime > 0) {
                pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
            }
            if (jdbcMaxWaitTime > 0) {
                pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
            }
            if (jdbcPingEnabled == true) {
                pooledDataSource.setPoolPingEnabled(true);
                if (jdbcPingQuery != null) {
                    pooledDataSource.setPoolPingQuery(jdbcPingQuery);
                }
                pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
            }
            if (jdbcDefaultTransactionIsolationLevel > 0) {
                pooledDataSource.setDefaultTransactionIsolationLevel(jdbcDefaultTransactionIsolationLevel);
            }
            dataSource = pooledDataSource;
        }

        if (dataSource instanceof PooledDataSource) {
            // ACT-233: connection pool of Ibatis is not properely initialized if this is not called!
            ((PooledDataSource) dataSource).forceCloseAll();
        }
    }

    if (databaseType == null) {
        initDatabaseType();
    }
}

From source file:org.activiti.crystalball.simulator.impl.cfg.SimulationEngineConfigurationImpl.java

License:Apache License

protected void initDataSource() {
    if (dataSource == null) {
        if (dataSourceJndiName != null) {
            try {
                dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
            } catch (Exception e) {
                throw new ActivitiException(
                        "couldn't lookup datasource from " + dataSourceJndiName + ": " + e.getMessage(), e);
            }//  ww  w  .j  a va2  s . co m

        } else if (jdbcUrl != null) {
            if ((jdbcDriver == null) || (jdbcUrl == null) || (jdbcUsername == null)) {
                throw new ActivitiException(
                        "DataSource or JDBC properties have to be specified in a process engine configuration");
            }

            log.fine("initializing datasource to db: " + jdbcUrl);

            PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver,
                    jdbcUrl, jdbcUsername, jdbcPassword);

            if (jdbcMaxActiveConnections > 0) {
                pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
            }
            if (jdbcMaxIdleConnections > 0) {
                pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
            }
            if (jdbcMaxCheckoutTime > 0) {
                pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
            }
            if (jdbcMaxWaitTime > 0) {
                pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
            }
            if (jdbcPingEnabled == true) {
                pooledDataSource.setPoolPingEnabled(true);
                if (jdbcPingQuery != null) {
                    pooledDataSource.setPoolPingQuery(jdbcPingQuery);
                }
                pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
            }
            dataSource = pooledDataSource;
        }

        if (dataSource instanceof PooledDataSource) {
            // ACT-233: connection pool of Ibatis is not properely initialized if this is not called!
            ((PooledDataSource) dataSource).forceCloseAll();
        }
    }

    if (databaseType == null) {
        initDatabaseType();
    }
}

From source file:org.activiti.engine.AbstractEngineConfiguration.java

License:Apache License

protected void initDataSource() {
    if (dataSource == null) {
        if (dataSourceJndiName != null) {
            try {
                dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
            } catch (Exception e) {
                throw new ActivitiException(
                        "couldn't lookup datasource from " + dataSourceJndiName + ": " + e.getMessage(), e);
            }/*from w  w  w. ja  v a 2s.c  o m*/

        } else if (jdbcUrl != null) {
            if ((jdbcDriver == null) || (jdbcUsername == null)) {
                throw new ActivitiException(
                        "DataSource or JDBC properties have to be specified in a process engine configuration");
            }

            logger.debug("initializing datasource to db: {}", jdbcUrl);

            if (logger.isInfoEnabled()) {
                logger.info("Configuring Datasource with following properties (omitted password for security)");
                logger.info("datasource driver: " + jdbcDriver);
                logger.info("datasource url : " + jdbcUrl);
                logger.info("datasource user name : " + jdbcUsername);
            }

            PooledDataSource pooledDataSource = new PooledDataSource(this.getClass().getClassLoader(),
                    jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);

            if (jdbcMaxActiveConnections > 0) {
                pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
            }
            if (jdbcMaxIdleConnections > 0) {
                pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
            }
            if (jdbcMaxCheckoutTime > 0) {
                pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
            }
            if (jdbcMaxWaitTime > 0) {
                pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
            }
            if (jdbcPingEnabled == true) {
                pooledDataSource.setPoolPingEnabled(true);
                if (jdbcPingQuery != null) {
                    pooledDataSource.setPoolPingQuery(jdbcPingQuery);
                }
                pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
            }
            if (jdbcDefaultTransactionIsolationLevel > 0) {
                pooledDataSource.setDefaultTransactionIsolationLevel(jdbcDefaultTransactionIsolationLevel);
            }
            dataSource = pooledDataSource;
        }

        if (dataSource instanceof PooledDataSource) {
            // ACT-233: connection pool of Ibatis is not properly
            // initialized if this is not called!
            ((PooledDataSource) dataSource).forceCloseAll();
        }
    }

    if (databaseType == null) {
        initDatabaseType();
    }
}

From source file:org.activiti.MybatisMultiTenantDatasourceConfiguration.java

License:Apache License

public DataSource getDataSource() {
    logger.info("Creating datasource for tenant " + tenantId + " at jdbc url " + jdbcUrl);

    DataSource dataSource = null;
    if (jdbcUrl != null) {

        if ((jdbcDriver == null) || (jdbcUsername == null)) {
            throw new ActivitiException(
                    "DataSource or JDBC properties have to be specified in a process engine configuration");
        }/*from  w  w  w  . j  a va 2 s  .  c  om*/

        PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver,
                jdbcUrl, jdbcUsername, jdbcPassword);

        if (jdbcMaxActiveConnections > 0) {
            pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
        }
        if (jdbcMaxIdleConnections > 0) {
            pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
        }
        if (jdbcMaxCheckoutTime > 0) {
            pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
        }
        if (jdbcMaxWaitTime > 0) {
            pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
        }
        if (jdbcPingEnabled == true) {
            pooledDataSource.setPoolPingEnabled(true);
            if (jdbcPingQuery != null) {
                pooledDataSource.setPoolPingQuery(jdbcPingQuery);
            }
            pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
        }
        if (jdbcDefaultTransactionIsolationLevel > 0) {
            pooledDataSource.setDefaultTransactionIsolationLevel(jdbcDefaultTransactionIsolationLevel);
        }

        dataSource = pooledDataSource;
    }

    if (dataSource instanceof PooledDataSource) {
        // ACT-233: connection pool of Ibatis is not properly
        // initialized if this is not called!
        ((PooledDataSource) dataSource).forceCloseAll();
    }

    return dataSource;
}

From source file:org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.java

License:Apache License

protected void initDataSource() {
    if (dataSource == null) {
        if (dataSourceJndiName != null) {
            try {
                dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
            } catch (Exception e) {
                throw new ProcessEngineException(
                        "couldn't lookup datasource from " + dataSourceJndiName + ": " + e.getMessage(), e);
            }/*w ww.  j a  v  a2 s.  c  om*/

        } else if (jdbcUrl != null) {
            if ((jdbcDriver == null) || (jdbcUrl == null) || (jdbcUsername == null)) {
                throw new ProcessEngineException(
                        "DataSource or JDBC properties have to be specified in a process engine configuration");
            }

            PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver,
                    jdbcUrl, jdbcUsername, jdbcPassword);

            if (jdbcMaxActiveConnections > 0) {
                pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
            }
            if (jdbcMaxIdleConnections > 0) {
                pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
            }
            if (jdbcMaxCheckoutTime > 0) {
                pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
            }
            if (jdbcMaxWaitTime > 0) {
                pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
            }
            if (jdbcPingEnabled == true) {
                pooledDataSource.setPoolPingEnabled(true);
                if (jdbcPingQuery != null) {
                    pooledDataSource.setPoolPingQuery(jdbcPingQuery);
                }
                pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
            }
            dataSource = pooledDataSource;
        }

        if (dataSource instanceof PooledDataSource) {
            // ACT-233: connection pool of Ibatis is not properely initialized if this is not called!
            ((PooledDataSource) dataSource).forceCloseAll();
        }
    }

    if (databaseType == null) {
        initDatabaseType();
    }
}

From source file:org.flowable.common.engine.impl.AbstractEngineConfiguration.java

License:Apache License

protected void initDataSource() {
    if (dataSource == null) {
        if (dataSourceJndiName != null) {
            try {
                dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
            } catch (Exception e) {
                throw new FlowableException(
                        "couldn't lookup datasource from " + dataSourceJndiName + ": " + e.getMessage(), e);
            }/*from w ww  .ja  va  2s .  c  o m*/

        } else if (jdbcUrl != null) {
            if ((jdbcDriver == null) || (jdbcUsername == null)) {
                throw new FlowableException(
                        "DataSource or JDBC properties have to be specified in a process engine configuration");
            }

            logger.debug("initializing datasource to db: {}", jdbcUrl);

            if (logger.isInfoEnabled()) {
                logger.info("Configuring Datasource with following properties (omitted password for security)");
                logger.info("datasource driver : {}", jdbcDriver);
                logger.info("datasource url : {}", jdbcUrl);
                logger.info("datasource user name : {}", jdbcUsername);
            }

            PooledDataSource pooledDataSource = new PooledDataSource(this.getClass().getClassLoader(),
                    jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);

            if (jdbcMaxActiveConnections > 0) {
                pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
            }
            if (jdbcMaxIdleConnections > 0) {
                pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
            }
            if (jdbcMaxCheckoutTime > 0) {
                pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
            }
            if (jdbcMaxWaitTime > 0) {
                pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
            }
            if (jdbcPingEnabled) {
                pooledDataSource.setPoolPingEnabled(true);
                if (jdbcPingQuery != null) {
                    pooledDataSource.setPoolPingQuery(jdbcPingQuery);
                }
                pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
            }
            if (jdbcDefaultTransactionIsolationLevel > 0) {
                pooledDataSource.setDefaultTransactionIsolationLevel(jdbcDefaultTransactionIsolationLevel);
            }
            dataSource = pooledDataSource;
        }
    }

    if (databaseType == null) {
        initDatabaseType();
    }
}

From source file:org.flowable.engine.common.AbstractEngineConfiguration.java

License:Apache License

protected void initDataSource() {
    if (dataSource == null) {
        if (dataSourceJndiName != null) {
            try {
                dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
            } catch (Exception e) {
                throw new FlowableException(
                        "couldn't lookup datasource from " + dataSourceJndiName + ": " + e.getMessage(), e);
            }//  ww w  .j av  a  2  s.  c  om

        } else if (jdbcUrl != null) {
            if ((jdbcDriver == null) || (jdbcUsername == null)) {
                throw new FlowableException(
                        "DataSource or JDBC properties have to be specified in a process engine configuration");
            }

            logger.debug("initializing datasource to db: {}", jdbcUrl);

            if (logger.isInfoEnabled()) {
                logger.info("Configuring Datasource with following properties (omitted password for security)");
                logger.info("datasource driver : {}", jdbcDriver);
                logger.info("datasource url : {}", jdbcUrl);
                logger.info("datasource user name : {}", jdbcUsername);
            }

            PooledDataSource pooledDataSource = new PooledDataSource(this.getClass().getClassLoader(),
                    jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);

            if (jdbcMaxActiveConnections > 0) {
                pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
            }
            if (jdbcMaxIdleConnections > 0) {
                pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
            }
            if (jdbcMaxCheckoutTime > 0) {
                pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
            }
            if (jdbcMaxWaitTime > 0) {
                pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
            }
            if (jdbcPingEnabled == true) {
                pooledDataSource.setPoolPingEnabled(true);
                if (jdbcPingQuery != null) {
                    pooledDataSource.setPoolPingQuery(jdbcPingQuery);
                }
                pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
            }
            if (jdbcDefaultTransactionIsolationLevel > 0) {
                pooledDataSource.setDefaultTransactionIsolationLevel(jdbcDefaultTransactionIsolationLevel);
            }
            dataSource = pooledDataSource;
        }

        if (dataSource instanceof PooledDataSource) {
            // ACT-233: connection pool of Ibatis is not properly
            // initialized if this is not called!
            ((PooledDataSource) dataSource).forceCloseAll();
        }
    }

    if (databaseType == null) {
        initDatabaseType();
    }
}

From source file:uap.workflow.engine.cfg.ProcessEngineConfigurationImpl.java

License:Apache License

protected void initDataSource() {
    if (dataSource == null) {
        if (dataSourceJndiName != null) {
            try {
                dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);
            } catch (Exception e) {
                throw new WorkflowException(
                        "couldn't lookup datasource from " + dataSourceJndiName + ": " + e.getMessage(), e);
            }//from ww  w .j  a v a2s  .c o  m
        } else if (jdbcUrl != null) {
            if ((jdbcDriver == null) || (jdbcUrl == null) || (jdbcUsername == null)) {
                throw new WorkflowException(
                        "DataSource or JDBC properties have to be specified in a process engine configuration");
            }
            log.fine("initializing datasource to db: " + jdbcUrl);
            PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver,
                    jdbcUrl, jdbcUsername, jdbcPassword);
            if (jdbcMaxActiveConnections > 0) {
                pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections);
            }
            if (jdbcMaxIdleConnections > 0) {
                pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections);
            }
            if (jdbcMaxCheckoutTime > 0) {
                pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime);
            }
            if (jdbcMaxWaitTime > 0) {
                pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime);
            }
            if (jdbcPingEnabled == true) {
                pooledDataSource.setPoolPingEnabled(true);
                if (jdbcPingQuery != null) {
                    pooledDataSource.setPoolPingQuery(jdbcPingQuery);
                }
                pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor);
            }
            dataSource = pooledDataSource;
        }
        if (dataSource instanceof PooledDataSource) {
            // ACT-233: connection pool of Ibatis is not properely
            // initialized if this is not called!
            ((PooledDataSource) dataSource).forceCloseAll();
        }
    }
    if (databaseType == null) {
        initDatabaseType();
    }
}