码迷,mamicode.com
首页 > 其他好文 > 详细

Jfinal开发代码碎片_导出报表_配置druid数据源_使用guava

时间:2015-06-02 20:07:22      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:

1.使用jfinal扩展包jfinal-ext-3.1.2.jar导出Excel报表,他需要依赖poi-3.12.jar

jai包下载地址:http://files.cnblogs.com/files/zhougaojun/jfinal-ext_poi.zip

导出Excel方法:

//导出Excel
    public void excel()throws Exception{
        List<Record> list = Db.find("select * from activeaction_6_new");
        PoiRender render = new PoiRender(list);
        String[] headers = {"ID","游戏ID","渠道ID","MAC","IP","设备版本","设备信息","IDFA","IDFV","激活时间","区域","用户ID","游戏版本号"};
        String[] columns= {"id","gameId","channelId","mac","ip","deviceos","deviceinfo","idfa","idfv","actionTime","area","userid","gamever"};
        render(render.headers(headers).columns(columns).sheetName("所有激活").fileName("adreport.doc"));
    }

2.使用guava-16.0.1.jar工具类

jar包下载地址:   http://files.cnblogs.com/files/zhougaojun/guava-16.0.1.zip

使用实例:

List<Cat> list = Lists.newArrayList(new Cat("catA",5),new Cat("catB",10)
System.out.println(Strings.isNullOrEmpty(null));
System.out.println(Strings.nullToEmpty("aa"));
//一行一行读取日志文件封装成一个list
List<String> list50 = Files.readLines(new File("E:\\50_phoneadv.20150521.png\\50_phoneadv.zqgame.com.log_20150521.log"),Charset.defaultCharset());

 3.jfinal使用druid数据源配置

  下载地址:http://central.maven.org/maven2/com/alibaba/druid/1.0.4/

    @Override
    public void configPlugin(Plugins me) {
        loadPropertyFile("dbconfig.properties");
        DruidPlugin  druidPlugin =new DruidPlugin(getProperty("main.jdbc.database"),
                getProperty("main.jdbc.user"),
                getProperty("main.jdbc.password"),
                getProperty("jdbc.driverClass"));
        druidPlugin.addFilter(new StatFilter());
        druidPlugin.setValidationQuery("SELECT 1");
        druidPlugin.setTestWhileIdle(true);
        druidPlugin.setTestOnBorrow(true);
        druidPlugin.setTestOnReturn(true);
        WallFilter wall = new WallFilter();
        wall.setDbType("mysql");
        druidPlugin.addFilter(wall);
        me.add(druidPlugin);
        ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
        mappingClass(arp);    
        arp.setShowSql(false);
        SqlReporter.setLogger(true);
        me.add(arp);
    }

 

Jfinal开发代码碎片_导出报表_配置druid数据源_使用guava

标签:

原文地址:http://www.cnblogs.com/zhougaojun/p/4547401.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!