jfinal只用dao,取得主鍵

C3p0Plugin c3p0Plugin = new C3p0Plugin("jdbc:mysql://192.168.0.104:3306/ultrax?characterEncoding=GBK&zeroDateTimeBehavior=convertToNull", 
"root", "ftxdb");
c3p0Plugin.start();  
ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin.getDataSource());
arp.addMapping("pre_forum_thread", "tid",Article.class);
// arp.addMapping("pre_forum_post", "pid",Article.class);
arp.setShowSql(true);
arp.start();

Article a = new Article();
a.set("fid", 2);
a.set("author", "admin");
a.set("authorid", 1);
a.set("subject", "test ");
// a.set("message", "test content333333333");
a.save();

System.out.println(a.getInt("tid")); //取得主鍵 html


 參考: http://xcodebox.com/2013/04/8700.html mysql

相關文章
相關標籤/搜索