config插件配置:
ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
arp.addSqlTemplate("sysuser.sql");
arp.setShowSql(true);
_MappingKit.mapping(arp);
me.add(arp);
sysuser.sql文件内容
#namespace("user")
#sql("login")
select * from sys_user where username = ? and passwd = ?
#end
#end
controller测试调用
SysUser user = SysUser.dao.template("user.login", "admin", "123456").findFirst();
renderJson(user);
exceptin异常堆栈
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1020)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:431)
at com.jfinal.plugin.activerecord.Model.find(Model.java:678)
at com.jfinal.plugin.activerecord.Model.find(Model.java:688)
... 58 more