Example usage for org.apache.ibatis.datasource DataSourceException DataSourceException

List of usage examples for org.apache.ibatis.datasource DataSourceException DataSourceException

Introduction

In this page you can find the example usage for org.apache.ibatis.datasource DataSourceException DataSourceException.

Prototype

public DataSourceException(String message, Throwable cause) 

Source Link

Usage

From source file:addrAction.JndiDataSourceFactory.java

License:Apache License

public void setProperties(Properties properties) {
    try {//  w w w.ja va2  s  .c  om
        InitialContext initCtx = null;
        Properties env = getEnvProperties(properties);
        if (env == null) {
            initCtx = new InitialContext();
        } else {
            initCtx = new InitialContext(env);
        }

        if (properties.containsKey(INITIAL_CONTEXT) && properties.containsKey(DATA_SOURCE)) {
            Context ctx = (Context) initCtx.lookup(properties.getProperty(INITIAL_CONTEXT));
            dataSource = (DataSource) ctx.lookup(properties.getProperty(DATA_SOURCE));
        } else if (properties.containsKey(DATA_SOURCE)) {
            dataSource = (DataSource) initCtx.lookup(properties.getProperty(DATA_SOURCE));
        }

    } catch (NamingException e) {
        throw new DataSourceException(
                "There was an error configuring JndiDataSourceTransactionPool. Cause: " + e, e);
    }
}

From source file:org.nanoframework.orm.mybatis.plugin.C3P0DataSourceFactory.java

License:Apache License

public C3P0DataSourceFactory() {
    try {//from  w w w. ja v a2s  . com
        Class<?> ComboPooledDataSource = Class.forName("com.mchange.v2.c3p0.ComboPooledDataSource");
        this.dataSource = (DataSource) ComboPooledDataSource.newInstance();
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        throw new DataSourceException(e.getMessage(), e);
    }
}

From source file:org.nanoframework.orm.mybatis.plugin.DruidDataSourceFactory.java

License:Apache License

public DruidDataSourceFactory() {
    try {/*from   w w  w  .j a  v  a  2  s  .  c  o m*/
        Class<?> DruidDataSource = Class.forName("com.alibaba.druid.pool.DruidDataSource");
        this.dataSource = (DataSource) DruidDataSource.newInstance();
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        throw new DataSourceException(e.getMessage(), e);
    }
}

From source file:org.nanoframework.orm.mybatis.plugin.TomcatJdbcPoolDataSourceFactory.java

License:Apache License

public TomcatJdbcPoolDataSourceFactory() {
    try {//www.j  ava 2s.  c o m
        TomcatJdbcDataSource = Class.forName("org.apache.tomcat.jdbc.pool.DataSource");
        this.dataSource = (DataSource) TomcatJdbcDataSource.newInstance();
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        throw new DataSourceException(e.getMessage(), e);
    }
}