Java Code Examples for com.jfinal.plugin.druid.DruidPlugin#start()

The following examples show how to use com.jfinal.plugin.druid.DruidPlugin#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JFinalConfigExt.java    From jfinal-ext3 with Apache License 2.0 5 votes vote down vote up
/**
 * DruidPlugin
 * @param prop : property
 * @return
 */
private DruidPlugin getDruidPlugin(String ds) {
	String url = this.getProperty(String.format("db.%s.url", ds));
	url = String.format(URL_TEMPLATE, ds, url);
	String endsWith = "?characterEncoding=UTF8&zeroDateTimeBehavior=CONVERT_TO_NULL";
	if (!url.endsWith(endsWith)) {
		url += endsWith;
	}
	
	String password = this.getProperty(String.format(PASSWORD_TEMPLATE, ds));
	String pkey = this.getProperty(String.format(PASSWORD_PKEY_TEMPLATE, ds));
	String user = this.getProperty(String.format(USER_TEMPLATE, ds));
	
	DruidPlugin dp = new DruidPlugin(url, user, password);
	dp.setPublicKey(pkey);
	dp.setFilters("config,stat,wall");
	dp.setInitialSize(this.getPropertyToInt(String.format(INITSIZE_TEMPLATE, ds)));
	dp.setMaxActive(this.getPropertyToInt(String.format(MAXSIZE_TEMPLATE, ds)));
	
	if (this.geRuned) {
		dp.start();
		BaseModelGenerator baseGe = new BaseModelGenerator(this.getBaseModelPackage(), this.getBaseModelOutDir());
		baseGe.setGenerateChainSetter(true);
		baseGe.setTemplate(base_model_template);
		ModelGenerator modelGe = new ModelGenerator(this.getModelPackage(), this.getBaseModelPackage(), this.getModelOutDir());
		modelGe.setGenerateDaoInModel(this.getGeDaoInModel());
		modelGe.setTemplate(model_template);
		Generator ge = new Generator(dp.getDataSource(), baseGe, modelGe);
		MappingKitGenerator mappingKitGe = new MappingKitGenerator(this.getModelPackage(), this.getModelOutDir());
		mappingKitGe.setMappingKitClassName(ds.toUpperCase()+this.getMappingKitClassName());
		mappingKitGe.setTemplate(mapping_kit_template);
		ge.setMappingKitGenerator(mappingKitGe);
		ge.setGenerateDataDictionary(this.getGeDictionary());
		ge.generate();
	}
	
	return dp;
}
 
Example 2
Source File: _JFinalGenerator.java    From sdb-mall with Apache License 2.0 5 votes vote down vote up
public static DataSource getDataSource() {
	String jdbcUrl = "jdbc:mysql://127.0.0.1:3306/"+DB_NAME+"?useUnicode=true&characterEncoding=UTF-8";
	String user = DB_USER_NAME;
	String password = DB_USER_PWD;
	DruidPlugin druidPlugin = new DruidPlugin(jdbcUrl, user, password);
	druidPlugin.start();
	return druidPlugin.getDataSource();
}
 
Example 3
Source File: Test.java    From my_curd with Apache License 2.0 5 votes vote down vote up
static void init() {
    Prop jdbcProp = PropKit.use("config-dev.txt");
    DruidPlugin dp = new DruidPlugin(jdbcProp.get("oa.jdbc.url"),
            jdbcProp.get("oa.jdbc.user"), jdbcProp.get("oa.jdbc.password"), jdbcProp.get("oa.jdbc.driver"));
    dp.start();
    ActiveRecordPlugin arp = new ActiveRecordPlugin(ActivitiConfig.DATASOURCE_NAME, dp);
    arp.setDialect(new MysqlDialect());
    arp.setShowSql(true);
    arp.start();
    ActivitiPlugin ap = new ActivitiPlugin();
    ap.start();
}
 
Example 4
Source File: MysqlDataSourceUtils.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * 获得数据库数据源,用于代码生成器
 *
 * @return 数据源
 */
public static DataSource getDataSource() {
    // 根据实际情况配置
    Prop configProp = PropKit.use("jdbc.properties");
    DruidPlugin dp = new DruidPlugin(configProp.get("jdbc.url"), configProp.get("jdbc.user"),
            configProp.get("jdbc.password"), configProp.get("jdbc.driver"));
    dp.start();
    return dp.getDataSource();
}
 
Example 5
Source File: _JFinalDemoGenerator.java    From sqlhelper with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static DataSource getDataSource() {
	DruidPlugin druidPlugin = DemoConfig.createDruidPlugin();
	druidPlugin.start();
	return druidPlugin.getDataSource();
}