jFinal怎样连接sqlserver
2017-11-07
1.修改配置文件
jdbc.url= jdbc:sqlserver://localhost;databaseName=jfinal_demo
jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.user=sa
jdbc.pwd=123456
devMode = true
2.配置插件
public void configPlugin(Plugins me) {
// 配置C3p0数据库连接池插件
C3p0Plugin c3p0Plugin = new C3p0Plugin(getProperty("jdbc.url"), getProperty("jdbc.user"), getProperty("jdbc.pwd").trim(),getProperty("jdbc.driver"));
me.add(c3p0Plugin);
// 配置ActiveRecord插件
ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
arp.setDialect(new AnsiSqlDialect());
me.add(arp);
arp.addMapping("blog", Blog.class);
}