1、创建新数据库配置目录sdk
2、拷贝custom目录下的 db.properties到sdk目录
3、修改新的db.properties文件
4、拷贝dao.json,改名为dao1.json。同目录操作
5、修改,conf节点下的paths
conf : {
type : "org.nutz.ioc.impl.PropertiesProxy",
fields : {
paths : ["config/sdk/"]
}
}
6、修改dao为dao1
dao1 : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"}],
fields : {
executor : {refer:"cacheExecutor"}
}
},
7、使用dao1作为数据源
@IocBean
public class TestJob implements Job {
private static final Log log = Logs.get();
@Inject
protected Dao dao;
@Inject
protected Dao dao1;
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap data = context.getJobDetail().getJobDataMap();
String taskId = context.getJobDetail().getKey().getName();
String hi = data.getString("hi");
log.info("Test Job hi::" + hi);
dao.update(Sys_task.class, Chain.make("exeAt", (int) (System.currentTimeMillis() / 1000)).add("exeResult", "执行成功"), Cnd.where("id", "=", taskId));
List<Record> ls= dao1.query("config",null);
System.out.println("config长度"+ls.size());
}
}
输出:
For example:> "UPDATE sys_task SET exeAt=1477983030 ,exeResult='执行成功' WHERE id='ef570cc2738f46a38c0c95166a881a74'"
2016-11-01 14:50:30,070 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - SELECT * FROM config
config长度53