Examples of SqlCommand


Examples of it.eng.spago.dbaccess.sql.SQLCommand

   *
   */
  public boolean executeUpdateQuery(Map<String , Object> params, JSONObject metaParams) throws Throwable, Exception{
    boolean toReturn = true;
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
   
    logger.debug("IN");
   
    try {

      Connection jdbcConnection = datasource.getConnection();
      jdbcConnection.setAutoCommit(false);
      dataConnection = getDataConnection(jdbcConnection);

      String statement = SQLStatements.getStatement((String)params.get( STMT ));
      logger.debug("Parameter [" + STMT + "] is equals to [" + statement + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( statement ), "Parameter [" + STMT + "] cannot be null or empty");
     
      String numParsStr = (String) params.get( NUM_PARS );
      int numPars = (numParsStr != null)?Integer.parseInt(numParsStr):0;
      logger.debug("Parameter [ numPars ] is equals to [" + numPars + "]");
     
      sqlCommand = dataConnection.createUpdateCommand(statement);
      dataConnection.initTransaction();
     
      if (numPars > 0){
        List inputParameter = new ArrayList(numPars);

        if (metaParams == null){ 
          Assert.assertTrue(metaParams == null, "Parameter [" + metaParams + "] cannot be null or empty.");         
        }else{
          JSONArray queryPars = (JSONArray)metaParams.get("queryParams");
          //for (int j=0; j<queryPars.length(); j++){
          for (int j=0; j<numPars; j++){
            JSONObject obj = (JSONObject)queryPars.get(j);
            String paramType = (String)obj.get("type");
            String paramName = (String)obj.get("name");
            String paramValue = (String)params.get(paramName);
            //if value isn't valorized, checks the defualt (if it's defined into meta section)
            if (paramValue == null){
              try{
                paramValue =  (String)obj.get("default");
              }catch(JSONException je ){
                logger.error("param " + paramName + "in JSON template not found. Parameter value is null!");
                paramValue = null;
              }
            }
            inputParameter.add(dataConnection.createDataField(paramName,getParamType(paramType), paramValue));             
         
        }
       
        dataResult = sqlCommand.execute(inputParameter);
      }else{
        dataResult = sqlCommand.execute();
      }
      dataConnection.commitTransaction();
    } // try
    catch (Exception ex) {
      toReturn = false;
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

   */

  private String getLovResult(IEngUserProfile profile,String statement) throws Exception {
    String resStr = null;
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
    try {
      //gets connection
      DataSourceUtilities dsUtil = new DataSourceUtilities();
      Connection conn = dsUtil.getConnection(profile,dataSource);
      dataConnection = dsUtil.getDataConnection(conn);
      sqlCommand = dataConnection.createSelectCommand(statement, false);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult.getDataObject();
      SourceBean result = scrollableDataResult.getSourceBean();
      resStr = result.toXML(false);
      resStr = resStr.trim();
      if(resStr.startsWith("<?")) {
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

  public List validateValues(IEngUserProfile profile, BIObjectParameter biparam) throws Exception {
    List toReturn = new ArrayList();
    List<String> values = biparam.getParameterValues();
    List parameterValuesDescription = new ArrayList();
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
    String statement = null;
    SourceBean result = null;
    try {
      statement = getValidationQuery(profile, biparam, values);
      //gets connection
      DataSourceUtilities dsUtil = new DataSourceUtilities();
      Connection conn = dsUtil.getConnection(profile,dataSource);
      dataConnection = dsUtil.getDataConnection(conn);
      sqlCommand = dataConnection.createSelectCommand(statement, false);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult.getDataObject();
      result = scrollableDataResult.getSourceBean();
    } finally {
      Utils.releaseResources(dataConnection, sqlCommand, dataResult);
    }
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

       ResponseContainer responseContainer, String datasource, String statement, List columnsNames) throws EMFInternalError {
      //ResponseContainer responseContainer, String pool, String statement, List columnsNames) throws EMFInternalError {
    Object result = null;
    //DataConnectionManager dataConnectionManager = null;
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
    try {
      /*dataConnectionManager = DataConnectionManager.getInstance();
      dataConnection = dataConnectionManager.getConnection(pool);
      */
      //gets connection
      DataSourceUtilities dsUtil = new DataSourceUtilities();
      Connection conn = dsUtil.getConnection(requestContainer,datasource);
      dataConnection = dsUtil.getDataConnection(conn);

      sqlCommand = dataConnection.createSelectCommand(statement, false);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult
          .getDataObject();
      List temp = Arrays.asList(scrollableDataResult.getColumnNames());
      columnsNames.addAll(temp);
      result = scrollableDataResult.getSourceBean();
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

    // get CHECKED_QUERY statment
    String statement = getQueryStatement("CHECKED_QUERY", parameters);

    // exec CHECKED_QUERY
    ScrollableDataResult scrollableDataResult = null;
    SQLCommand sqlCommand = null;
    DataConnection dataConnection = null;
    DataResult dataResult = null;
    String pool = null;
    try {
      pool = (String) config.getAttribute("POOL");
      dataConnection = DataConnectionManager.getInstance().getConnection(
          pool);
      sqlCommand = dataConnection.createSelectCommand(statement);
      dataResult = sqlCommand.execute();
      scrollableDataResult = (ScrollableDataResult) dataResult
          .getDataObject();
      SourceBean chekedObjectsBean = scrollableDataResult.getSourceBean();
      List checkedObjectsList = chekedObjectsBean
          .getAttributeAsList("ROW");
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

   public static Object executeSelect(RequestContainer requestContainer,
      ResponseContainer responseContainer, String pool, String statement) throws EMFInternalError {
    Object result = null;
    DataConnectionManager dataConnectionManager = null;
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
    try {
      dataConnectionManager = DataConnectionManager.getInstance();
      dataConnection = dataConnectionManager.getConnection(pool);
      sqlCommand = dataConnection.createSelectCommand(statement);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult
          .getDataObject();
      result = scrollableDataResult.getSourceBean();
    } catch (Exception ex) {
      TracerSingleton.log(Constants.NOME_MODULO,
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

    Session aSession = null;
    Transaction tx = null;
   
    // exec CHECKED_QUERY
    ScrollableDataResult scrollableDataResult = null;
    SQLCommand sqlCommand = null;
    DataConnection dataConnection = null;
    DataResult dataResult = null;
    try {
      aSession = HibernateUtil.currentSession();
      tx = aSession.beginTransaction();
      Connection jdbcConnection = aSession.connection();
      dataConnection = DelegatedHibernateConnectionListService.getDataConnection(jdbcConnection);
          sqlCommand = dataConnection.createSelectCommand(statement);
          dataResult = sqlCommand.execute();
          scrollableDataResult = (ScrollableDataResult) dataResult.getDataObject();
      SourceBean chekedObjectsBean = scrollableDataResult.getSourceBean();
      List checkedObjectsList = chekedObjectsBean
          .getAttributeAsList("ROW");
      for (int i = 0; i < checkedObjectsList.size(); i++) {
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

     * @return the SQL command
     */
    public static SQLCommand createStatementSql(final DataConnection dataConnection,
            final String statement, final String type) {
     
        SQLCommand sqlCommand = null;
        if (type.equalsIgnoreCase("INSERT"))
            sqlCommand = dataConnection.createInsertCommand(statement);
        else if (type.equalsIgnoreCase("UPDATE"))
            sqlCommand = dataConnection.createUpdateCommand(statement);
        else if (type.equalsIgnoreCase("DELETE"))
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

    protected static Object executeQuery(DataConnection dataConnection, final String statement,
            final String type, final ArrayList inputParameters) throws Exception {
       
      logger.debug("IN");
        SQLCommand sqlCommand = null;
        DataResult dataResult = null;
        Object result = null;
        try {
            // Create the command to execute
            sqlCommand = createStatementSql(dataConnection, statement, type);
            if ((inputParameters != null) && (inputParameters.size() != 0)) {
                dataResult = sqlCommand.execute(inputParameters);
            } else
                dataResult = sqlCommand.execute();
            if (type.equalsIgnoreCase("SELECT")) {
                ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult
                        .getDataObject();
                result = scrollableDataResult.getSourceBean();
            } // if (type.equalsIgnoreCase("SELECT"))
View Full Code Here

Examples of it.eng.spago.dbaccess.sql.SQLCommand

    public static Object executeSelect(RequestContainer requestContainer, ResponseContainer responseContainer,
      String datasource, String statement) throws EMFInternalError {
  logger.debug("IN");
  Object result = null;
  DataConnection dataConnection = null;
  SQLCommand sqlCommand = null;
  DataResult dataResult = null;
  try {
      DataSourceUtilities dsUtil = new DataSourceUtilities();
      Connection conn = dsUtil.getConnection(requestContainer,datasource);
      dataConnection = dsUtil.getDataConnection(conn);
      sqlCommand = dataConnection.createSelectCommand(statement);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult.getDataObject();
      result = scrollableDataResult.getSourceBean();
  } finally {
      Utils.releaseResources(dataConnection, sqlCommand, dataResult);
      logger.debug("OUT");
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.