Search in sources :

Example 1 with DruidPlugin

use of com.jfinal.plugin.druid.DruidPlugin in project my_curd by qinyou.

the class AppConfig method configPlugin.

@Override
public void configPlugin(Plugins me) {
    DruidPlugin dbPlugin = new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));
    // druid 监控
    dbPlugin.addFilter(new StatFilter());
    WallFilter wall = new WallFilter();
    wall.setDbType("mysql");
    dbPlugin.addFilter(wall);
    ActiveRecordPlugin arp = new ActiveRecordPlugin(dbPlugin);
    arp.setShowSql(PropKit.getBoolean("devMode"));
    arp.setDialect(new MysqlDialect());
    MappingKit.mapping(arp);
    me.add(dbPlugin);
    me.add(arp);
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) MysqlDialect(com.jfinal.plugin.activerecord.dialect.MysqlDialect) DruidPlugin(com.jfinal.plugin.druid.DruidPlugin) StatFilter(com.alibaba.druid.filter.stat.StatFilter) ActiveRecordPlugin(com.jfinal.plugin.activerecord.ActiveRecordPlugin)

Example 2 with DruidPlugin

use of com.jfinal.plugin.druid.DruidPlugin in project my_curd by qinyou.

the class SchemaInfoUtil method main.

public static void main(String[] args) {
    // 注意 InformationSchema=true
    DruidPlugin dp = new DruidPlugin("jdbc:mysql://127.0.0.1/my_curd?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useInformationSchema=true", "root", "123456");
    dp.start();
    Dialect mysqlDialect = new MysqlDialect();
    SchemaInfoUtil util = new SchemaInfoUtil(mysqlDialect, dp.getDataSource());
    List<Table> tables = util.getAllTableInfo(true);
    DbKit.getConfig().getDialect();
    DbKit.getConfig().getDataSource();
    System.out.println(JsonKit.toJson(tables));
}
Also used : MysqlDialect(com.jfinal.plugin.activerecord.dialect.MysqlDialect) DruidPlugin(com.jfinal.plugin.druid.DruidPlugin) MysqlDialect(com.jfinal.plugin.activerecord.dialect.MysqlDialect) Dialect(com.jfinal.plugin.activerecord.dialect.Dialect)

Aggregations

MysqlDialect (com.jfinal.plugin.activerecord.dialect.MysqlDialect)2 DruidPlugin (com.jfinal.plugin.druid.DruidPlugin)2 StatFilter (com.alibaba.druid.filter.stat.StatFilter)1 WallFilter (com.alibaba.druid.wall.WallFilter)1 ActiveRecordPlugin (com.jfinal.plugin.activerecord.ActiveRecordPlugin)1 Dialect (com.jfinal.plugin.activerecord.dialect.Dialect)1