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


Java MapHandler类代码示例

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


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

示例1: queryMap

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
/**
 * 查询对应的数据,返回单条记录(列名 => 数据)
 */
public Map<String, Object> queryMap(String sql, Object... params) {
    Map<String, Object> map;
    try {
        map = queryRunner.query(sql, new MapHandler(), params);
    } catch (SQLException e) {
        logger.error("查询出错!");
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return map;
}
 
开发者ID:smxc,项目名称:garlicts,代码行数:15,代码来源:JdbcTemplate.java

示例2: findRecord

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
/**
 * Find one record via arbitrary SQL and return it as a hashmap
 *
 * @param sql
 * @param args
 * @return
 */
public Map<String, Object> findRecord(String sql, Object... args) {
    QueryRunner runner = new QueryRunner(dataSource);
    MapHandler handler = new MapHandler();
    try {
        return runner.query(sql, handler, args);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:17,代码来源:DB.java

示例3: queryMap

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
public static Map<String, Object> queryMap(QueryRunner runner, String sql, Object... params) {
    Map<String, Object> result;
    try {
        result = runner.query(sql, new MapHandler(), params);
    } catch (SQLException e) {
        logger.error("查询出错!", e);
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return result;
}
 
开发者ID:thinkhoon,项目名称:tkhoon,代码行数:12,代码来源:DBUtil.java

示例4: selectOneBySql

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
@Override
public <T> T selectOneBySql(String sql, Object[] params, Class<T> classz) {

    QueryRunner queryRunner = new QueryRunner();

    Connection conn = getDbConnectionFactory().getConnection();

    printSQL(sql, params);
    try {
        if (classz.isAssignableFrom(Model.class)) {
            List<T> list = (List<T>) queryRunner.query(conn, sql, new AnnotationBeanListHandler(classz), params);
            if (list.size() > 0) {
                return list.get(0);
            }
            return null;

        } else if (baseType.contains(classz)) {
            return queryRunner.query(conn, sql, new ScalarHandler<T>(), params);
        } else {
            Map map = queryRunner.query(conn, sql, new MapHandler(), params);
            return (T) map;
        }
    } catch (SQLException e) {
        throw new RuntimeException(e);
    } finally {
        getDbConnectionFactory().releaseConnection(conn);
    }
}
 
开发者ID:treeleafj,项目名称:treeleaf,代码行数:29,代码来源:DefaultDBOperator.java

示例5: findGeometryByPoint

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
@Override
public Object findGeometryByPoint(String sql, String point, Server server)
		throws Exception {
	Connection conn = ConnectionManager.getConnectionW(server);
	MapHandler mh = new MapHandler();
	QueryRunner qr = new QueryRunner();
	Map<String, Object> response = new HashMap<String, Object>();
	try {
		response = qr.query(conn, sql, mh, point);
	} finally {
		ConnectionManager.closeConnection(conn);
	}
	return response;
}
 
开发者ID:MxSIG,项目名称:TableAliasV60,代码行数:15,代码来源:GeometriaDaoImpl.java

示例6: findGeometryByCvegeo

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
@Override
public Object findGeometryByCvegeo(String sql, String cvegeo, Server server)
		throws Exception {
	Connection conn = ConnectionManager.getConnectionW(server);
	MapHandler mh = new MapHandler();
	QueryRunner qr = new QueryRunner();
	Map<String, Object> response = new HashMap<String, Object>();
	try {
		response = qr.query(conn, sql, mh, cvegeo);
	} finally {
		ConnectionManager.closeConnection(conn);
	}
	return response;
}
 
开发者ID:MxSIG,项目名称:TableAliasV60,代码行数:15,代码来源:GeometriaDaoImpl.java

示例7: query

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
public static Map query(String sql, Object... params) {
		try {
            QueryRunner qRunner = new QueryRunner(MySQLConnTools.getMySQLDataSource());
			Map obj = qRunner.query(sql, new MapHandler(), params);
			return obj;
		} catch (SQLException e) {
//			logger.error(e.getMessage());
			e.printStackTrace();
		} 
		return null;
	}
 
开发者ID:RangerWolf,项目名称:Finance-News-Helper,代码行数:12,代码来源:MySQLUtils.java

示例8: findMap

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
/**
 * //TODO 根据sql查询一个map
 * 
 * @param sql
 * @param params
 * @return
 */
public static Map<String, Object> findMap(String sql, Object... params) {
    Map<String, Object> map;
    try {
        map = getQueryRunner().query(sql, new MapHandler(), params);
    } catch (SQLException e) {
        logger.error("queryMap.查询map出错:" + sql, e);
        throw new QueryException(e);
    }
    logger.debug("sql:" + sql + "\n  params:" + Arrays.toString(params));
    return map;
}
 
开发者ID:mattxia,项目名称:unique-web,代码行数:19,代码来源:DB.java

示例9: queryForMap

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
public MutableMap<String, Object> queryForMap(Connection conn, String sql) {
    return MapAdapter.adapt(this.query(conn, sql, new MapHandler()));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:4,代码来源:JdbcHelper.java

示例10: getFood

import org.apache.commons.dbutils.handlers.MapHandler; //导入依赖的package包/类
/**
 * 从Mysql得到Food
 *
 * @param foodId id
 * @return map
 * @throws SQLException
 */
@Deprecated
public Map<String, Object> getFood(int foodId) throws SQLException {
    return queryRunner.query("select * from food where id = ? LIMIT 1", new MapHandler(), foodId);
}
 
开发者ID:WhiteBlue,项目名称:eleme-hackathon,代码行数:12,代码来源:CoreService.java


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