一、查询操作:
1.map型:
按条件的精确查询,返回单条记录的字段值
import java.util.Map; import uap.web.exception.BusinessException; import nc.bs.framework.common.NCLocator; import nc.itf.uap.IUAPQueryBS; import nc.jdbc.framework.processor.MapProcessor;
select pk_org from po_order where pk_order='1001A0100000004DOFYZ' and dr=0 private static Map<String, Object> queryDate(String query) throws BusinessException { Map<String, Object> result = null; IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class); try { result = (Map<String, Object>) bs.executeQuery(query, new MapProcessor()); } catch (Exception e) { e.printStackTrace(); } return result; }
数据格式
{pk_org=0001A1100000000012VN}
2.List型:
按条件的批量查询,返回多条记录的字段值
import nc.jdbc.framework.processor.MapListProcessor;
private List<Map<String,Object>> queryData() throws BusinessException { String query = "select billmaker,pk_org,pk_org_v from po_order"; List<Map<String,Object>> result = null; //nc自带的查询工具 IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class); try { result = (List<Map<String,Object>>) bs.executeQuery(query, new MapListProcessor()); } catch (Exception e) { e.printStackTrace(); } return result; }
数据格式
[ { pk_org_v = 0001 A1100000000012VM, pk_org = 0001 A1100000000012VN, billmaker = 1001 A210000000000R48 }, { pk_org_v = 0001 A1100000000012VM, pk_org = 0001 A1100000000012VN, billmaker = 1001 A1100000000005EK }, { pk_org_v = 0001 A1100000000012VM, pk_org = 0001 A1100000000012VN, billmaker = 1001 A210000000087SME }, { pk_org_v = 0001 A1100000000012VM, pk_org = 0001 A1100000000012VN, billmaker = 1001 A2100000000881FT }, { pk_org_v = 0001 A1100000000012VM, pk_org = 0001 A1100000000012VN, billmaker = 1001 A2100000000881ER }, { pk_org_v = 0001 A1100000000012VM, pk_org = 0001 A1100000000012VN, billmaker = 1001 A210000000087SL3 } ]
3.Bean型
Object result = ""; String sql = "select * from " + tableName + "_mid" + " where updatetime >='" + updatetime + "'and pk_org = '"+pkOrg+"' order by updatetime"; try { String className = "nc.vo.dti.tsdp.vo." + tableName + "VO"; Class<?> c = Class.forName(className); result = getBaseDao().executeQuery(sql, new BeanListProcessor(c)); } catch (ClassNotFoundException e) { e.printStackTrace(); throw new BusinessException(e.getMessage()); } JSONArray jsonArr = JSONArray.fromObject(result);
二、增删改操作
import nc.bs.dao.BaseDAO; BaseDAO baseDao = new BaseDAO(); int i = baseDao.executeUpdate("update ic_purchasein_b set vnotebody = 'Y' where cgeneralhid='a'"); int i1 = baseDao.executeUpdate("insert into ic_purchasein_b ....."); int i2 = baseDao.executeUpdate("delete ic_purchasein_b where....."); //i为执行成功结果条数