Examples of DataServiceFault


Examples of org.wso2.carbon.dataservices.core.DataServiceFault

            stmt = conn.prepareStatement(processedSQL);
          }
        } else if (queryType == SQLQuery.DS_QUERY_TYPE_STORED_PROC) {
          stmt = conn.prepareCall(processedSQL);
        } else {
          throw new DataServiceFault("Unsupported query type: " + queryType);
        }
      } else {
        inTheMiddleOfABatch = true;
      }
     
      if (!inTheMiddleOfABatch) {
        /* set query timeout */
        if (this.isHasQueryTimeout()) {
          stmt.setQueryTimeout(this.getQueryTimeout());
        }
        /* set fetch direction */
        if (this.isHasFetchDirection()) {
          stmt.setFetchDirection(this.getFetchDirection());
        }
        /* set fetch size - user's setting */
        if (this.isHasFetchSize()) {
          stmt.setFetchSize(this.getFetchSize());
        } else {
          /* stream data by sections - avoid the full result set to be loaded to memory,
           * and only stream if there aren't any OUT parameters, MySQL fails in the scenario
           * of streaming and OUT parameters, so the possibility is there for other DBMSs */
          if (!this.hasOutParams()) {
            stmt.setFetchSize(this.getOptimalRSFetchSize());
          }
        }
        /* set max field size */
        if (this.isHasMaxFieldSize()) {
          stmt.setMaxFieldSize(this.getMaxFieldSize());
        }
        /* set max rows */
        if (this.isHasMaxRows()) {
          stmt.setMaxRows(this.getMaxRows());
        }
      }
     
      int currentOrdinal = 0;
      InternalParam param = null;
      ParamValue value = null;
      int count = this.getParamCount();
      for (int i = 1; i <= count; i++) {
        param = params.getParam(i);
        value = param.getValue();
        /* handle array values, if value is null, this param has to be an OUT param */
        if (value != null && value.getValueType() == ParamValue.PARAM_VALUE_ARRAY) {
          for (String arrayElement : value.getArrayValue()) {
            this.setParamInPreparedStatement(stmt, param.getName(), arrayElement,
                param.getSqlType(), param.getType(), queryType, currentOrdinal);
            currentOrdinal++;
          }
        } else { /* scalar value */         
          this.setParamInPreparedStatement(stmt, param.getName(),
              value != null ? value.getScalarValue() : null,
              param.getSqlType(), param.getType(), queryType, currentOrdinal);
          currentOrdinal++;
        }       
      }
     
      /* if we are in JDBC batch processing mode, batch it! */
      if (this.isJDBCBatchRequest()) {
        stmt.addBatch();
      }
     
      return stmt;
    } catch (SQLException e) {
      throw new DataServiceFault(e, "Error in 'createProcessedPreparedStatement'");
    }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

        } else if (DBConstants.DataTypes.ORACLE_REF_CURSOR.equals(sqlType)) {
            setOracleRefCusor(stmt, index);
        } else if (DBConstants.DataTypes.UDT.equals(sqlType)){
            setUserDefinedType(stmt, index, paramName, paramType);
        } else{
            throw new DataServiceFault("[" + this.getDataService().getName() +
                "]  Found Unsupported data type : " + sqlType + " as input parameter.");
        }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

    try {
      if (value != null) {
          time = DBUtils.getTime(value);
      }
    } catch (ParseException e) {
      throw new DataServiceFault(e,
          "Incorrect Time format for parameter : " + paramName
              + ". Time should be in the format hh:mm:ss");
    }
    if ("IN".equals(paramType)) {
      if (queryType == SQLQuery.DS_QUERY_TYPE_NORMAL) {
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

    try {
      if (value != null) {
          timestamp = DBUtils.getTimestamp(value);
      }
    } catch (ParseException e) {
      throw new DataServiceFault(e,
          "Incorrect Timestamp format for parameter : "
              + paramName
              + ". Timestamp should be in one of following formats "
              + "yyyy-MM-dd'T'hh:mm:ss.sss'+'hh:mm, "
              + "yyyy-MM-dd'T'hh:mm:ss.sss'-'hh:mm, "
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

      } else {
        ((CallableStatement) sqlQuery).registerOutParameter(i + 1,
            java.sql.Types.DATE);
      }
    } catch (IllegalArgumentException e) {
      throw new DataServiceFault(e, "Incorrect date format for parameter  : "
          + paramName + ". Date should be in yyyy-mm-dd format.");
    }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

                return new ParamValue(elementValue.toString());
      } else if(type.equals(DBConstants.DataTypes.UDT)){
                elementValue = cs.getObject(ordinal);
                return new ParamValue((Struct) elementValue);
            } else {
        throw new DataServiceFault("Unsupported data type: " + type);
      }
    } catch (SQLException e) {
      throw new DataServiceFault(e, "Error in getting sql output parameter values.");
    }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

          prefetchData, prefetchedData);
    } else if (type == SQLQuery.DS_QUERY_TYPE_STORED_PROC) {
      return this.processStoredProcQuery(xmlWriter, params, queryLevel,
          prefetchData, prefetchedData);
    } else {
      throw new DataServiceFault("Unsupported query type: " + type);
    }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

          } else {
              /* process the result of the request, no need to cache the data */
              result.serializeAndConsume(new NullOutputStream());
          }
        } catch (XMLStreamException e) {
          throw new DataServiceFault(e, "Error in request box result serializing");
        }
      }
    }
    return null;
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

    if (username != null) {
      /* set user roles */
      try {
        dsRequest.setUserRoles(DBUtils.getUserRoles(msgContext));
      } catch (Exception e) {
        throw new DataServiceFault(e, "Error setting user roles");
      }
    }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

      return responseElement;
    } else { /* if no response i.e. in-only, execute the request now */
      try {
        ds.executeInOnly();
      } catch (XMLStreamException e) {
        throw new DataServiceFault(e, "Error in DS non result invoke.");
      }
      return null;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.