|
楼主 |
发表于 2013-1-7 09:19:17
|
显示全部楼层
在java中返回Table类型
1、使用KSQL.select方法
例如- import com.justep.system.data.KSQL;
- String query = "select t.sOrgFID, t.sOrgFName, t.sOrgName from SA_ResourceControl t where t.sResourceID=:resource and t.sTypeID=:type";
- HashMap<String, Object> params = new HashMap<String, Object>();
- params.put("type", typeID);
- params.put("resource", resourceID);
- Table table = KSQL.select(query, params, "/system/data", null);
复制代码 2、使用SQL.select方法
例如- import com.justep.system.data.SQL;
- String oracle = "SELECT RPRODUCTID , RPRODUCTNAME , (SELECT RCATEGORYNAME FROM DEMO_REPORTPRODUCTCATEGORY WHERE DEMO_REPORTPRODUCTCATEGORY.RCATEGORYID = DEMO_REPORTPRODUCTS.RCATEGORYID) AS RCATEGORYNAME , (SELECT RCOMPANYNAME FROM DEMO_REPORTSUPPLIERS WHERE DEMO_REPORTSUPPLIERS.RSUPPLIERID = DEMO_REPORTPRODUCTS.RSUPPLIERID)AS RCOMPANYNAME, RQUANTITYPERUNIT,RUNITPRICE,RUNITSINSTOCK FROM DEMO_REPORTPRODUCTS";
- String mssql = "SELECT RPRODUCTID, RPRODUCTNAME, (SELECT RCATEGORYNAME FROM DEMO_REPORTPRODUCTCATEGORY WHERE DEMO_REPORTPRODUCTCATEGORY.RCATEGORYID = DEMO_REPORTPRODUCTS.RCATEGORYID) AS RCATEGORYNAME , (SELECT RCOMPANYNAME FROM DEMO_REPORTSUPPLIERS WHERE DEMO_REPORTSUPPLIERS.RSUPPLIERID = DEMO_REPORTPRODUCTS.RSUPPLIERID)AS RCOMPANYNAME, RQUANTITYPERUNIT,RUNITPRICE,RUNITSINSTOCK FROM DEMO_REPORTPRODUCTS";
- HashMap<String,String> sqlMap = new HashMap<String,String>();
- sqlMap.put(SQL.DEFAULT_DB_NAME,mssql);
- sqlMap.put(DatabaseProduct.ORACLE.name(),oracle);
- sqlMap.put(DatabaseProduct.MSSQL.name(),mssql);
- sqlMap.put(DatabaseProduct.KINGBASE.name(),oracle);
- sqlMap.put(DatabaseProduct.SYBASE.name(),mssql);
- sqlMap.put(DatabaseProduct.DB2.name(),oracle);
- sqlMap.put(DatabaseProduct.MYSQL.name(),mssql);
- return SQL.select(sqlMap,null,"/demo/report/data");
复制代码 3、使用BizUtils.resultSet2Table方法
例如- import com.justep.system.util.BizUtils;
- Connection conn = ModelUtils.getConnection("/x5demo/rich/data");
- Statement exeistStmt = conn.createStatement();
- String sql = "select fGoodsCode,fGoodsName from X5_Goods";
- ResultSet rs = exeistStmt.executeQuery(sql);
- Table table = BizUtils.resultSet2Table(rs, (Model)null);
复制代码 |
|