Java 类org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport 实例源码

项目:alfresco-jscript-extensions    文件:ScriptDatabaseService.java   
public Map<String, Object>[] query(String dataSourceName, String sql, Object... params) {
    SimpleJdbcDaoSupport daoSupport = getDaoSupport(dataSourceName);
    Preconditions.checkNotNull(daoSupport," daosupport is null- please check the datasource name");

    List<Map<String, Object>> result = daoSupport.getSimpleJdbcTemplate().queryForList(sql, params);
    Map<String, Object>[] arr = new Map[result.size()];
    for (int i=0; i < result.size(); i++) {
        arr[i] = result.get(i);
    }
    return arr;
}
项目:alfresco-jscript-extensions    文件:ScriptDatabaseService.java   
private SimpleJdbcDaoSupport getDaoSupport(String dataSourceName) {
    Object dsBean = applicationContext.getBean(dataSourceName);

    if (dsBean instanceof DataSource) {
        SimpleJdbcDaoSupport daoSupport = new SimpleJdbcDaoSupport();
        daoSupport.setDataSource((DataSource) dsBean);
        return daoSupport;
    }
    else {

        throw new AlfrescoRuntimeException("dataSource '" + dataSourceName + "' not found.");
    }
}
项目:alfresco-jscript-extensions    文件:ScriptDatabaseService.java   
@ScriptMethod()
public int update(String dataSourceName, String sql, Object... params) {
    SimpleJdbcDaoSupport daoSupport = getDaoSupport(dataSourceName);
    Preconditions.checkNotNull(daoSupport," daosupport is null- please check the datasource name");
    return daoSupport.getSimpleJdbcTemplate().update(sql, params);
}