Demo entry 6350160

java

   

Submitted by anonymous on Mar 07, 2017 at 06:44
Language: Java. Code size: 904 Bytes.

 public static boolean injection(Ioc ioc) {
        if (jdbc_prop.containsKey("url") && jdbc_prop.containsKey("username") && jdbc_prop.containsKey("password")) {
            DataSource dataSource;
            try {
                dataSource = DruidDataSourceFactory.createDataSource(jdbc_prop);
            } catch (Exception e) {
                throw new TipException("数据库连接失败, 请检查数据库配置");
            }
            SampleActiveRecord sampleActiveRecord = ioc.getBean(SampleActiveRecord.class);
            if (null != sampleActiveRecord) {
                sampleActiveRecord.setSql2o(new Sql2o(dataSource));
            } else {
                SampleActiveRecord activeRecord = new SampleActiveRecord(dataSource);
                ioc.addBean(activeRecord);
            }
            return true;
        }
        ioc.addBean(new SampleActiveRecord());
        return false;
    }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).