1 package hessian.demo.server; 2 3 import hessian.demo.ICustomer; 4 import dinamica.*; 5 import dinamica.hessian.BasicService; 6 import java.sql.*; 7 8 17 public class Customer extends BasicService implements ICustomer 18 { 19 20 23 public Recordset getCustomer(String custID) throws Throwable 24 { 25 26 Connection conn = getDataSource().getConnection(); 28 29 try 30 { 31 String sql = StringUtil.replace(getResource("customer.sql"), "{id}", custID); 33 String sql1 = StringUtil.replace(getResource("orders.sql"), "{id}", custID); 34 String sql2 = getResource("details.sql"); 35 36 Db db = new Db( conn ); 38 Recordset rs = db.get(sql); 39 40 Recordset rsOrders = db.get(sql1); 42 43 rs.first(); 45 rs.setChildrenRecordset(rsOrders); 46 47 while (rsOrders.next()) 49 { 50 String cmd = StringUtil.replace(sql2, "{id}", rsOrders.getString("orderid")); 51 Recordset rsDetail = db.get(cmd); 52 rsOrders.setChildrenRecordset(rsDetail); 53 } 54 55 return rs; 57 } 58 catch (Throwable e) 59 { 60 throw e; 61 } 62 finally 63 { 64 if (conn!=null) 65 conn.close(); 66 } 67 68 } 69 70 } 71 | Popular Tags |