jfinal main 链接数据源

public static void main(String[] args) {

    C3p0Plugin cp = new C3p0Plugin("jdbc:mysql://localhost/safe", "root", "root");
    cp.start();
    ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);
   arp.start();
  arp.addMapping("driver", Driver.class);
  List<Driver> drivers = Driver.dao.find("select * from driver limit 0,20");
  for(Driver d:drivers){
    Set<Entry<String, Object>> set = d.getAttrsEntrySet();
    Iterator<Entry<String, Object>> it = set.iterator();
    System.out.println("=================");
    while(it.hasNext()){
      Entry<String, Object> next = it.next();
      System.out.println(next.getKey()+":"+next.getValue());
    }

    System.out.println("=================");
  }

}

 

posted @ 2016-06-18 11:00  phyxis_xu  阅读(341)  评论(0编辑  收藏  举报