Search in sources :

Example 1 with DB2WallProvider

use of com.alibaba.druid.wall.spi.DB2WallProvider in project druid by alibaba.

the class WallFilter method init.

@Override
public synchronized void init(DataSourceProxy dataSource) {
    if (null == dataSource) {
        LOG.error("dataSource should not be null");
        return;
    }
    if (this.dbType == null || this.dbType.trim().length() == 0) {
        if (dataSource.getDbType() != null) {
            this.dbType = dataSource.getDbType();
        } else {
            this.dbType = JdbcUtils.getDbType(dataSource.getRawJdbcUrl(), "");
        }
    }
    if (dbType == null) {
        dbType = JdbcUtils.getDbType(dataSource.getUrl(), null);
    }
    if (//
    JdbcUtils.MYSQL.equals(dbType) || //
    JdbcUtils.MARIADB.equals(dbType) || JdbcUtils.H2.equals(dbType)) {
        if (config == null) {
            config = new WallConfig(MySqlWallProvider.DEFAULT_CONFIG_DIR);
        }
        provider = new MySqlWallProvider(config);
    } else if (JdbcUtils.ORACLE.equals(dbType) || JdbcUtils.ALI_ORACLE.equals(dbType)) {
        if (config == null) {
            config = new WallConfig(OracleWallProvider.DEFAULT_CONFIG_DIR);
        }
        provider = new OracleWallProvider(config);
    } else if (JdbcUtils.SQL_SERVER.equals(dbType) || JdbcUtils.JTDS.equals(dbType)) {
        if (config == null) {
            config = new WallConfig(SQLServerWallProvider.DEFAULT_CONFIG_DIR);
        }
        provider = new SQLServerWallProvider(config);
    } else if (JdbcUtils.POSTGRESQL.equals(dbType) || JdbcUtils.ENTERPRISEDB.equals(dbType)) {
        if (config == null) {
            config = new WallConfig(PGWallProvider.DEFAULT_CONFIG_DIR);
        }
        provider = new PGWallProvider(config);
    } else if (JdbcUtils.DB2.equals(dbType)) {
        if (config == null) {
            config = new WallConfig(DB2WallProvider.DEFAULT_CONFIG_DIR);
        }
        provider = new DB2WallProvider(config);
    } else {
        throw new IllegalStateException("dbType not support : " + dbType + ", url " + dataSource.getUrl());
    }
    provider.setName(dataSource.getName());
    this.inited = true;
}
Also used : OracleWallProvider(com.alibaba.druid.wall.spi.OracleWallProvider) DB2WallProvider(com.alibaba.druid.wall.spi.DB2WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) PGWallProvider(com.alibaba.druid.wall.spi.PGWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider)

Aggregations

DB2WallProvider (com.alibaba.druid.wall.spi.DB2WallProvider)1 MySqlWallProvider (com.alibaba.druid.wall.spi.MySqlWallProvider)1 OracleWallProvider (com.alibaba.druid.wall.spi.OracleWallProvider)1 PGWallProvider (com.alibaba.druid.wall.spi.PGWallProvider)1 SQLServerWallProvider (com.alibaba.druid.wall.spi.SQLServerWallProvider)1