Package org.wso2.carbon.dataservices.core

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


          }           
          }         
        }
        return connection;
    } catch (SQLException e) {
      throw new DataServiceFault(e, "Error in opening DBMS connection.");
    }
  }
View Full Code Here


        connection.close();
      } else if (force) {
        connection.close();
      }
    } catch (SQLException e) {
      throw new DataServiceFault(e, "Error in DBMS connection finalize.");
    }
  }
View Full Code Here

      /* no pre-fetch data */
      return null;
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      isError = true;
      throw new DataServiceFault(e, FaultCodes.DATABASE_ERROR,
          "Error in 'SQLQuery.processNormalQuery'");
    } finally {
      /* finalize the DB connection, close it if possible etc.. */
      if (!prefetchData || isError) {       
        this.finalizeConnection(conn, isError);
View Full Code Here

     
      return null;
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      isError = true;
      throw new DataServiceFault(e, FaultCodes.DATABASE_ERROR,
          "Error in 'SQLQuery.processStoredProcQuery'");
    } finally {
      /* close the DB connection */
      if (!prefetchData) {
          this.finalizeConnection(conn, isError);
View Full Code Here

            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

        } 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

    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

    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

      } 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

                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

TOP

Related Classes of org.wso2.carbon.dataservices.core.DataServiceFault

Copyright © 2018 www.massapicom. 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.