Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.PreparedStatementCreatorFactory.newPreparedStatementCreator()


    JdbcTemplate t = new JdbcTemplate(CachingDataSourceProvider.getInstance().getDataSource(uri));
    if (tableExists(table.getName(), uri)) {
      final String createStatement = table.getDeleteAllStatement();
      PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
          createStatement);
      t.update(creatorFactory.newPreparedStatementCreator(new Object[] {}));
    }
  }
}
View Full Code Here


    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
      "INSERT INTO partition_dimension_metadata (name,index_uri,db_type) VALUES (?,?,?)",
      new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
    creatorFactory.setReturnGeneratedKeys(true);
    int rows = j.update(creatorFactory
      .newPreparedStatementCreator(parameters), generatedKey);
    if (rows != 1)
      throw new HiveRuntimeException("Unable to create Partition Dimension: " + parameters);
    if (generatedKey.getKeyList().size() == 0)
      throw new HiveRuntimeException("Unable to retrieve generated primary key");
View Full Code Here

    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
      "UPDATE partition_dimension_metadata set name=?,index_uri=?,db_type=? where id=?",
      new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER});
    int rows = j.update(creatorFactory
      .newPreparedStatementCreator(parameters));
    if (rows != 1)
      throw new HiveRuntimeException("Unable to update Partition Dimension for id: " + partitionDimension.getId());
    // dependencies
    for (Resource r : partitionDimension.getResources())
View Full Code Here

    parameters = new Object[]{partitionDimension.getId()};
    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
      "DELETE from partition_dimension_metadata where id=?",
      new int[]{Types.INTEGER});
    int rows = j.update(creatorFactory.newPreparedStatementCreator(parameters));
    if (rows != 1)
      throw new HiveRuntimeException("Unable to delete Partition Dimension for id: " + partitionDimension.getId());
  }
}
View Full Code Here

   
    PreparedStatementCreatorFactory creatorFactory =
      new PreparedStatementCreatorFactory(insertSql(),getTypes());
    creatorFactory.setReturnGeneratedKeys(true);
   
    int rows = j.update(creatorFactory.newPreparedStatementCreator(getParameters(newObject)), generatedKey);
    if (rows != 1)
      throw new HiveRuntimeException("Unable to create Resource: "
          + getParameters(newObject));
    if (generatedKey.getKeyList().size() == 0)
      throw new HiveRuntimeException("Unable to retrieve generated primary key");
View Full Code Here

    params[params.length-1] = node.getId();
    types[types.length-1] = Types.INTEGER;
   
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(updateSql(),types);
   
    int rows = j.update(creatorFactory.newPreparedStatementCreator(params));
    if (rows != 1)
      throw new HiveRuntimeException("Unable to update node with id: " + node.getId());
   
    return node;
  }
View Full Code Here

   
    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
        "DELETE from node_metadata where id=?",
        new int[] { Types.INTEGER });
    int rows = j.update(creatorFactory
        .newPreparedStatementCreator(parameters));
    if (rows != 1)
      throw new HiveRuntimeException("Unable to delete node for id: " + node.getId());
    return node;
  }
View Full Code Here

      public Object doInTransaction(TransactionStatus arg0) {
        Integer rowsAffected = 0;
        for (SecondaryIndex secondaryIndex : resource.getSecondaryIndexes()) {
          PreparedStatementCreatorFactory deleteIndexFactory =
            Statements.newStmtCreatorFactory(sql.deleteAllSecondaryIndexKeysForResourceId(secondaryIndex), resource.getColumnType());
          rowsAffected += getJdbcTemplate().update(deleteIndexFactory.newPreparedStatementCreator(parameters));
        }
        return rowsAffected;
      }
    });
  }
View Full Code Here

    Collection<SimpleJdbcDaoSupport> sporkDaos = hive.connection().daoSupport().get(spork.getType(), AccessType.ReadWrite);
    PreparedStatementCreatorFactory stmtFactory =
      new PreparedStatementCreatorFactory(productInsertSql, new int[]{Types.INTEGER, Types.VARCHAR, Types.VARCHAR});
    Object[] parameters = new Object[]{spork.getId(), spork.getName(), spork.getType()};
    for (JdbcDaoSupport dao : sporkDaos)
      dao.getJdbcTemplate().update(stmtFactory.newPreparedStatementCreator(parameters));

    //Update the resource id so that the hive can locate it
    hive.directory().insertResourceId(resourceName, spork.getId(), spork.getType());
    //Finally we update the SecondaryIndex
    hive.directory().insertSecondaryIndexKey(resourceName, "name", spork.getName(), spork.getId());
View Full Code Here

      Object[] params = NamedParameterUtils.buildValueArray(parsedSql1, paramSource, null);
      List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql1, paramSource);
      PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse1, declaredParameters);
      pscf.setResultSetType( ResultSet.TYPE_FORWARD_ONLY );
      pscf.setUpdatableResults(false);
      PreparedStatementCreator preparedStatementCreator = pscf.newPreparedStatementCreator(params);
     
      //con.prepareStatement(theSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
     
      preparedStatement = preparedStatementCreator.createPreparedStatement(con);
      this.rs = preparedStatement.executeQuery();
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.