9416eaadb8dc834317a6b38902f584c35ba5d195.svn-base 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package xin.glue.ui.B.common;
  2. import java.sql.CallableStatement;
  3. import java.sql.SQLException;
  4. import java.util.ArrayList;
  5. import com.posdata.glue.biz.activity.PosActivity;
  6. import com.posdata.glue.biz.constants.PosBizControlConstants;
  7. import com.posdata.glue.context.PosContext;
  8. import com.posdata.glue.dao.PosGenericDao;
  9. import com.posdata.glue.dao.vo.PosParameter;
  10. /**
  11. *
  12. * @Description 调用存储过程
  13. * @author 梅贵平{meiguiping}
  14. * @date 2011-01-07 下午07:42:42
  15. * @JDK Version jdk1.4.2
  16. */
  17. public class XgSimpleProc extends PosActivity
  18. {
  19. public String runActivity(PosContext context)
  20. {
  21. PosGenericDao dao = this.getDao("mesdao");
  22. CallableStatement cstm = null;
  23. String sql = this.getProperty("sqlkey");
  24. int count = Integer.parseInt(this.getProperty("paramCount"));
  25. String[]procStat= (String[])context.get("procStat");
  26. if(procStat == null) return PosBizControlConstants.SUCCESS;
  27. int len = procStat.length;
  28. try
  29. {
  30. for(int j = 0; j < len ; j++)
  31. {
  32. cstm = dao.getCallableStatement(sql);
  33. String inParam = "";
  34. //int index = 1;
  35. for(int i = 1; i <= count ; i++)
  36. {
  37. inParam = this.getProperty("InParam"+i);
  38. if (inParam != null )
  39. {
  40. cstm.setString(i, ((String[])context.get(inParam))[j]);
  41. }
  42. else
  43. {
  44. cstm.registerOutParameter(i, java.sql.Types.VARBINARY);
  45. }
  46. }
  47. cstm.execute();
  48. }
  49. }catch(Exception ex)
  50. {
  51. logger.logError(ex.getMessage(), ex);
  52. }
  53. finally
  54. {
  55. if (cstm != null)
  56. {
  57. try
  58. {
  59. cstm.close();
  60. }
  61. catch (SQLException e)
  62. {
  63. logger.logWarn(e.getMessage(), e);
  64. }
  65. }
  66. }
  67. return PosBizControlConstants.SUCCESS;
  68. }
  69. }