Package org.apache.tuscany.das.rdb

Examples of org.apache.tuscany.das.rdb.Parameter


    InsertCommandImpl cmd = new InsertCommandImpl(statement.toString());
    Iterator params = parameters.iterator();
    for (int idx = 1; params.hasNext(); idx++) {
      Property property = (Property) params.next();
      Parameter p = new ParameterImpl();
      p.setName(property.getName());
      p.setType(property.getType());
      p.setConverter(getConverter(table, property.getName()));
      p.setIndex(idx);
      cmd.addParameter(p);

    }
    DebugUtil.debugln(getClass(), debug, statement.toString());
    return cmd;
View Full Code Here


        try {
            CallableStatement cs = jdbcConnection.prepareCall(queryString);

            Iterator inParams = parameters.inParams().iterator();
            while (inParams.hasNext()) {
                Parameter param = (Parameter) inParams.next();
                if (param.getIndex() == 0)
                    param.setIndex(queryString.getParameterIndex(param.getName()));
                cs.setObject(param.getIndex(), param.getValue());
            }

            // register out parameters
            Iterator outParams = parameters.outParams().iterator();
            while (outParams.hasNext()) {
                Parameter param = (Parameter) outParams.next();
                if (param.getIndex() == 0)
                    param.setIndex(queryString.getParameterIndex(param.getName()));
                DebugUtil.debugln(getClass(), debug, "Registering parameter " + param.getName());
                cs.registerOutParameter(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType()));
            }

            // Using execute because Derby does not currenlty support
            // executeQuery
            // for SP
            cs.execute();
            ResultSet results = cs.getResultSet();

            Iterator i = parameters.outParams().iterator();
            while (i.hasNext()) {
                Parameter param = (Parameter) i.next();
                param.setValue(cs.getObject(param.getIndex()));
            }

            return results;
        } catch (SQLException ex) {
            ex.printStackTrace();
View Full Code Here

    public void executeUpdateCall(Parameters parameters) throws SQLException {
        CallableStatement cs = jdbcConnection.prepareCall(queryString);

        Iterator inParams = parameters.inParams().iterator();
        while (inParams.hasNext()) {
            Parameter param = (Parameter) inParams.next();
            if (param.getIndex() == 0)
                param.setIndex(queryString.getParameterIndex(param.getName()));
            cs.setObject(param.getIndex(), param.getValue());
        }

        // register out parameters
        Iterator outParams = parameters.outParams().iterator();
        while (outParams.hasNext()) {
            Parameter param = (Parameter) outParams.next();
            if (param.getIndex() == 0)
                param.setIndex(queryString.getParameterIndex(param.getName()));
            DebugUtil.debugln(getClass(), debug, "Registering parameter " + param.getName());
            cs.registerOutParameter(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType()));
        }

        cs.execute();

        Iterator out = parameters.outParams().iterator();
        while (out.hasNext()) {
            Parameter param = (Parameter) out.next();
            param.setValue(cs.getObject(param.getIndex()));
        }

    }
View Full Code Here

    DeleteCommandImpl deleteCommand = new DeleteCommandImpl(getDeleteStatement(t));
   
    Iterator i = getDeleteParameters(t).iterator();
    for(int idx=1; i.hasNext(); idx++) {
      String property = (String) i.next();
      Parameter p = new ParameterImpl();
      p.setName(property);
      p.setType(SDODataTypes.OBJECT);
      p.setConverter(getConverter(t, property));
      p.setIndex(idx);
      deleteCommand.addParameter(p);
    }
    return deleteCommand;
  }
View Full Code Here

    public int executeUpdate(Parameters parameters) throws SQLException {
        DebugUtil.debugln(getClass(), debug, "Executing statement " + queryString.getPreparedString());
        PreparedStatement ps = getPreparedStatement();
        Iterator i = parameters.inParams().iterator();
        while (i.hasNext()) {
            Parameter param = (Parameter) i.next();
            if (param.getIndex() == 0)
                param.setIndex(queryString.getParameterIndex(param.getName()));
            Object value = param.getValue();
            DebugUtil.debugln(getClass(), debug, "Setting parameter " + param.getIndex() + " to " + value);
            if (value == null) {           
                ps.setNull(param.getIndex(), SDODataTypeHelper.sqlTypeFor(param.getType()));
            } else {          
                ps.setObject(param.getIndex(), value);
            }
        }
        return ps.executeUpdate();
    }
View Full Code Here

    protected PreparedStatement setParameters(PreparedStatement ps, Parameters parameters)
            throws SQLException {
        Iterator i = parameters.inParams().iterator();
        while (i.hasNext()) {
            Parameter param = (Parameter) i.next();
            if (param.getIndex() == 0)
                param.setIndex(queryString.getParameterIndex(param.getName()));
            ps.setObject(param.getIndex(), param.getValue());
        }
        return ps;
    }
View Full Code Here

  public void execute() {
    DebugUtil.debugln(getClass(), debug, "Executing change operation");
 
    Iterator i = writeCommand.getParameters().iterator();
    while (i.hasNext()) {
      Parameter parm = (Parameter) i.next();
      DebugUtil.debugln(getClass(), debug, "setting " + parm.getName() + " to " + dObject.get(parm.getName()));
      parm.setValue(dObject.get(parm.getName()));
    }

    writeCommand.execute();
              
    if ( isInsert && ( propagatedID != null )) {
View Full Code Here

  }

  public void addParameters(Collection updateParameters) {
    Iterator i = updateParameters.iterator();
    while ( i.hasNext()) {
      Parameter p = (Parameter) i.next();
      addParameter(p);
    }
  }
View Full Code Here

  public void add(Parameter param) {
    addParameter(param);
  }

  public Parameter findOrCreateParameterNamed(String name) {
    Parameter param = get(name);
    if (param == null) {
      param = new ParameterImpl(name);
      addParameter(param);
    }
    return param;
View Full Code Here

  public Parameter findOrCreateParameterWithIndex(int index, int direction,
      Type sdoType) {
    Iterator i = parameters.iterator();
    while (i.hasNext()) {
      Parameter param = (Parameter) i.next();

      if (param.getIndex() == index)
        return param;
    }
    DebugUtil.debugln(getClass(), debug,
        "Creating new parameter with index " + index);
    Parameter newParam = new ParameterImpl(index);
    newParam.setDirection(direction);
    newParam.setType(sdoType);
    addParameter(newParam);
    return newParam;
  }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.Parameter

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.