当前位置: 首页>>代码示例>>Java>>正文


Java MySQL类代码示例

本文整理汇总了Java中org.easyrec.utils.io.MySQL的典型用法代码示例。如果您正苦于以下问题:Java MySQL类的具体用法?Java MySQL怎么用?Java MySQL使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MySQL类属于org.easyrec.utils.io包,在下文中一共展示了MySQL类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getItems

import org.easyrec.utils.io.MySQL; //导入依赖的package包/类
@Override
public List<Item> getItems(RemoteTenant remoteTenant, String description, int start, int end) {
    List<Item> items;

    Object[] args = {remoteTenant.getId(), Item.DEFAULT_STRING_ITEM_TYPE};
    int[] argTypes = {Types.INTEGER, Types.VARCHAR};

    StringBuilder sql = new StringBuilder(SQL_GET_ITEMS);
    sql = MySQL.addLikeClause(sql, "DESCRIPTION", description);
    sql = MySQL.addLimitClause(sql, start, end);

    try {
        items = getJdbcTemplate().query(sql.toString(), args, argTypes, itemRowMapper);

        for (final Object item1 : items) {
            Item item = (Item) item1;
            item.setUrl(Text.matchMax(remoteTenant.getUrl(), item.getUrl()));
            item.setImageUrl(Text.matchMax(remoteTenant.getUrl(), item.getImageUrl()));
        }

        return items;
    } catch (Exception e) {
        logger.warn("An error occurred!", e);
        return null;
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:27,代码来源:ItemDAOMysqlImpl.java

示例2: getItemsWithRules

import org.easyrec.utils.io.MySQL; //导入依赖的package包/类
@Override
public List<Item> getItemsWithRules(Integer tenantId, String description, int start, int end) {
    StringBuilder sql = new StringBuilder().append(" SELECT ").append(" 	i.* ").append(" FROM  ")
            .append(" 	item i INNER JOIN ( ")
            .append(" 	SELECT stringid FROM (SELECT distinct itemFromId FROM itemassoc WHERE tenantid = ?");

    if (Strings.isNullOrEmpty(description))
        sql = MySQL.addLimitClause(sql, start, end);

    sql.append(") a INNER JOIN idmapping m ON (m.intId = a.itemFromId)) a ")
            .append("   	ON (i.itemid = stringid AND tenantid=?) ").append("  WHERE 1=1");
    sql = MySQL.addLikeClause(sql, "i.DESCRIPTION", description);

    if (!Strings.isNullOrEmpty(description))
        sql = MySQL.addLimitClause(sql, start, end);

    try {
        return getJdbcTemplate()
                .query(sql.toString(), new Object[]{tenantId, tenantId}, new int[]{Types.INTEGER, Types.INTEGER},
                        itemRowMapper);
    } catch (Exception e) {
        logger.error("failed to get items with rules", e);
        return null;
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:26,代码来源:ItemDAOMysqlImpl.java

示例3: count

import org.easyrec.utils.io.MySQL; //导入依赖的package包/类
@Override
public Integer count(Integer tenantId, String description) {
    StringBuilder sql = new StringBuilder().
            append(" SELECT Count(1) FROM ").
            append(DEFAULT_TABLE_NAME).
            append(" WHERE tenantId= ? ");

    Object[] args = {tenantId};
    int[] argTypes = {Types.INTEGER};

    sql = MySQL.addLikeClause(sql, "DESCRIPTION", description);

    try {
        return getJdbcTemplate().queryForInt(sql.toString(), args, argTypes);
    } catch (Exception e) {
        logger.debug("failed to get count", e);
        return 0;
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:20,代码来源:ItemDAOMysqlImpl.java

示例4: getItems

import org.easyrec.utils.io.MySQL; //导入依赖的package包/类
@Override
public List<Item> getItems(RemoteTenant remoteTenant, String description, int start, int end) {
    List<Item> items;

    Object[] args = {remoteTenant.getId(), Item.DEFAULT_STRING_ITEM_TYPE};
    int[] argTypes = {Types.INTEGER, Types.VARCHAR};

    StringBuilder sql = new StringBuilder(SQL_GET_ITEMS);
    sql = MySQL.addLikeClause(sql, "DESCRIPTION", description);
    sql = MySQL.addLimitClause(sql, start, end);

    try {
        items = getJdbcTemplate().query(sql.toString(), args, argTypes, itemRowMapper);

        for (final Object item1 : items) {
            Item item = (Item) item1;
            item.setUrl(Text.matchMax(remoteTenant.getUrl(), item.getUrl()));
            item.setImageUrl(Text.matchMax(remoteTenant.getUrl(), item.getImageUrl()));
        }

        return items;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:26,代码来源:ItemDAOMysqlImpl.java

示例5: doExecute

import org.easyrec.utils.io.MySQL; //导入依赖的package包/类
@Override
protected void doExecute(ExecutionControl control, SolrSimilarityStatistics stats) throws Exception {

    SolrSimilarityConfiguration configuration = getConfiguration();
    SolrSimilarityConfigurationInt config;

    Date start = MySQL.sanitzeForMysql56(new Date());
    stats.setStartDate(start);
    try {
        config = solrSimilarityService.mapTypesToConfiguration(configuration);
        logger.info("TenantId:" + config.getTenantId());
    } catch (Exception e) {
        stats.setException(e.getMessage());
        config = null;
    }
    if (config != null) {
        control.updateProgress(1, 4, "Indexing items");
        solrSimilarityService.addItemsToIndex(config);
        control.updateProgress(2, 4, "matching profiles");
        solrSimilarityService.matchProfiles(config, stats);
        control.updateProgress(3, 4, "removing old rules");
        solrSimilarityService.removeOldRules(config, stats);
        control.updateProgress(4, 4, "Finished");
    }
    stats.setEndDate(MySQL.sanitzeForMysql56(new Date()));
    stats.setDuration((stats.getEndDate().getTime() - stats.getStartDate().getTime())/1000);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:28,代码来源:SolrSimilarityGenerator.java

示例6: doExecute

import org.easyrec.utils.io.MySQL; //导入依赖的package包/类
@Override
protected void doExecute(ExecutionControl control, AggregatorStatistics stats) throws Exception {

    AggregatorConfiguration configuration = getConfiguration();
    AggregatorConfigurationInt intConfiguration;

    Date start = MySQL.sanitzeForMysql56(new Date());
    stats.setStartDate(start);

    try {
        intConfiguration = aggregatorService.mapTypesToConfiguration(configuration);
        logger.info("TenantId:" + intConfiguration.getTenantId());
    } catch (Exception e) {
        stats.setException(e.getMessage());
        intConfiguration = null;
    }
    if (intConfiguration != null) {
        if (control.isAbortRequested()) throw new Exception("UPA was manually aborted!");
        control.updateProgress(1, 3, "Getting users with actions.");
        List<Integer> users = aggregatorService.getUsersWithActions(intConfiguration);
        stats.setNrUsers(users.size());

        if (control.isAbortRequested()) throw new Exception("UPA was manually aborted!");
        int i=1;
        for (Integer user : users) {
            control.updateProgress(2, 3, "Aggregating user profiles " + i + "/" + stats.getNrUsers());
            List<ActionVO<Integer, Integer>> actions = aggregatorService.getActionsForUser(user, intConfiguration);
            aggregatorService.aggregateUserProfile(user, actions, intConfiguration);
            if (control.isAbortRequested()) throw new Exception("UPA was manually aborted!");
            i++;
        }
        stats.setNumberOfRulesCreated(i-1);
        stats.setNumberOfActionsConsidered(aggregatorService.getNumberOfActions(intConfiguration, null));
        // remove old Rules
        //aggregatorService.removeOldRules(intConfiguration, stats);
        //assocRuleMiningService.perform(configuration.getTenantId());

        control.updateProgress(3, 3, "Finished");
    } // TODO: else write logoutput 
    stats.setEndDate(MySQL.sanitzeForMysql56(new Date()));
    stats.setDuration((stats.getEndDate().getTime() - stats.getStartDate().getTime())/1000);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:43,代码来源:AggregatorGenerator.java


注:本文中的org.easyrec.utils.io.MySQL类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。