@Override
 public DataSource createAinitDataSource(Map<String, String> properties) {
   DataSource ds = null;
   try {
     ds = DruidDataSourceFactory.createDataSource(properties);
   } catch (Exception e) {
     log.error("create druid datasource error", e);
     try {
       ds = DruidDataSourceFactory.createDataSource(properties);
     } catch (Exception ex) {
       log.error("create druid datasource error", ex);
       throw new IllegalArgumentException("Cannot Create Datasource", ex);
     }
   }
   try {
     ((DruidDataSource) ds).init();
   } catch (SQLException e) {
     log.error("Init druid datasource errror", e);
     throw new IllegalArgumentException("Init Datasource Failure", e);
   }
   return ds;
 }
Exemplo n.º 2
0
  /** 初始化 */
  public void initialize(String configFile) {
    try {
      parseConfigFile(configFile);

      Properties props = new Properties();

      if (isXmlConfigFile()) loadXmlCfg(props);
      else loadPropCfg(props);

      props = filtrateCfg(props);
      dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(props);

      loadDefalutTransIsoLevel();
    } catch (Exception e) {
      try {
        unInitialize();
      } catch (Exception e2) {
      }
      throw new JdbcException(e);
    }
  }
Exemplo n.º 3
0
 private DruidSourceMysql() throws Exception {
   dataSource =
       DruidDataSourceFactory.createDataSource(MySqlConfigProperty.getInstance().getProperties());
 }