Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
  2. JSONObject obj = JSONFactoryUtil.createJSONObject();
  3. JSONObject jsonObjectReturn = JSONFactoryUtil.createJSONObject();
  4.  
  5. //JSONOBJECT RETURN
  6. JSONArray array = JSONFactoryUtil.createJSONArray();
  7.  
  8. Session session = null;
  9. Connection conn = null;
  10. CallableStatement callableStatement = null;
  11. CallableStatement csUpdate = null;
  12.  
  13.  
  14.  
  15. try {
  16. BeanLocator beanLocator = PortletBeanLocatorUtil
  17. .getBeanLocator("Mrcos-services-portlet");
  18. BasicDataSource bds = (BasicDataSource) beanLocator
  19. .locate("mrcosDataSourceTarget");
  20. conn = (Connection) bds.getConnection();
  21.  
  22. jsonObject = JSONFactoryUtil.createJSONObject(stringArray);
  23.  
  24. JSONArray jsonArray = jsonObject.getJSONArray("dataArray");
  25. JSONArray generateAlgo = TaxPayerLocalServiceUtil.checkAlgoEReceipt(stringArray);
  26.  
  27.  
  28.  
  29.  
  30. for (int i = 0; i < jsonArray.length(); i++) {
  31. obj = jsonArray.getJSONObject(i);
  32. obj2 = generateAlgo.getJSONObject(i);
  33.  
  34. callableStatement = (CallableStatement) conn
  35. .prepareCall("{call TaxpaymentSPv2(?,?,?,?,?,?,?,?)}");
  36.  
  37.  
  38. callableStatement.setString(1, obj.getString("rdoCode"));
  39. callableStatement.setString(2, obj.getString("rcoCode"));
  40. callableStatement.setString(3, obj.getString("tpTin"));
  41. callableStatement.setString(4, obj.getString("tpName"));
  42. callableStatement.setString(5, obj.getString("tpAddress"));
  43. callableStatement.setString(6, obj.getString("receiptType"));
  44. callableStatement.registerOutParameter(7, Types.VARCHAR);
  45. callableStatement.registerOutParameter(8, Types.VARCHAR);
  46.  
  47. callableStatement.executeUpdate();
  48.  
  49. String rNo = callableStatement.getString(7);
  50. String date = callableStatement.getString(8);
  51.  
  52.  
  53. //---->This is my second Array inside my JSON where im having an error <------
  54. String checkArray = obj.getString("checkArray");
  55. JSONArray jsonArrayCheck = JSONFactoryUtil.createJSONArray(stringArray);
  56.  
  57.  
  58. JSONArray jsonArray2 = jsonObject.getJSONArray("checkArray");
  59. System.out.println("..........." + jsonArray2);
  60.  
  61. jsonObjectReturn = JSONFactoryUtil.createJSONObject();
  62. jsonObjectReturn.put("rNo", rNo);
  63. jsonObjectReturn.put("date", date);
  64. array.put(jsonObjectReturn);
  65. }
  66.  
  67. return array;
  68.  
  69. {
  70. "dataArray": [{
  71.  
  72. "rdoCode": "001",
  73. "rcoCode": "002911",
  74. "tpTin": "200746409",
  75. "tpName": "JOHN DOE",
  76. "tpAddress": "LA CALIFORNIA",
  77. "receiptType":"ROR",
  78. "receiptMode":"AUTO",
  79. "manualReceiptNo":"",
  80. "checkArray":[{
  81. "ptchkNumber": 14546,
  82. "ptchkDate": 2014-01-01,
  83. "ptchkAmount": 5332,
  84. "ptchkStatus": ""
  85. }]
  86. }]
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement