Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.PreparedStatementCreatorFactory


  public void update(Resource resource) {
    int columnType = resource.getIdIndex().getColumnInfo().getColumnType();
    Object[] parameters = new Object[] { resource.getName(), resource.getPartitionDimension().getId(), JdbcTypeMapper.jdbcTypeToString(columnType),resource.isPartitioningResource(),resource.getId()};
    KeyHolder generatedKey = new GeneratedKeyHolder();
    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
        "UPDATE resource_metadata SET name=?,dimension_id=?,db_type=?,is_partitioning_resource=? WHERE id=?",
        new int[] {Types.VARCHAR,Types.INTEGER,Types.VARCHAR,Types.INTEGER,Types.BIT});
    creatorFactory.setReturnGeneratedKeys(true);
    int rows = j.update(creatorFactory
        .newPreparedStatementCreator(parameters), generatedKey);
    if (rows != 1)
      throw new HiveRuntimeException("Unable to update Resource: " + resource.getId());
   
    // dependencies
View Full Code Here


      new SecondaryIndexDao(ds).delete(si);
   
    Object[] parameters;
    parameters = new Object[] { resource.getId()};
    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
        "DELETE FROM resource_metadata WHERE id=?",
        new int[] { Types.INTEGER });
    int rows = j.update(creatorFactory
        .newPreparedStatementCreator(parameters));
    if (rows != 1)
      throw new HiveRuntimeException("Unable to delete resource for id: " + resource.getId());
  }
View Full Code Here

          JdbcTypeMapper.jdbcTypeToString(newObject.getColumnInfo()
              .getColumnType()) };
   
    KeyHolder generatedKey = new GeneratedKeyHolder();
    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
        "INSERT INTO secondary_index_metadata (resource_id,column_name,db_type) VALUES (?,?,?)",
        new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR });
    creatorFactory.setReturnGeneratedKeys(true);
    int rows = j.update(creatorFactory
        .newPreparedStatementCreator(parameters), generatedKey);
    if (rows != 1)
      throw new HiveRuntimeException("Unable to create secondary index: "
          + parameters);
    if (generatedKey.getKeyList().size() == 0)
View Full Code Here

          JdbcTypeMapper.jdbcTypeToString(secondaryIndex.getColumnInfo().getColumnType()),
          secondaryIndex.getId()};
   
    KeyHolder generatedKey = new GeneratedKeyHolder();
    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
        "UPDATE secondary_index_metadata SET resource_id=?,column_name=?,db_type=? WHERE id=?",
        new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER });
    creatorFactory.setReturnGeneratedKeys(true);
    int rows = j.update(creatorFactory
        .newPreparedStatementCreator(parameters), generatedKey);
    if (rows != 1)
      throw new HiveRuntimeException("Unable to update secondary index: " + secondaryIndex.getId());
  }
View Full Code Here

 
  public void delete(SecondaryIndex secondaryIndex) {
    Object[] parameters;
    parameters = new Object[] { secondaryIndex.getId()};
    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
        "DELETE FROM secondary_index_metadata WHERE id=?",
        new int[] { Types.INTEGER });
    int rows = j.update(creatorFactory
        .newPreparedStatementCreator(parameters));
    if (rows != 1)
      throw new HiveRuntimeException("Unable to delete secondary index for id: " + secondaryIndex.getId());
  }
View Full Code Here

   */
  public static void createTable(TableInfo table, String uri) {
    JdbcTemplate t = new JdbcTemplate(CachingDataSourceProvider.getInstance().getDataSource(uri));
    if (! tableExists(table.getName(), uri)) {
      final String createStatement = table.getCreateStatement();
      PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
          createStatement);
      t.update(creatorFactory.newPreparedStatementCreator(new Object[] {}));
    }
  }
View Full Code Here

 
  public static void emptyTable(TableInfo table, String uri) {
    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

      newObject.getIndexUri(),
      JdbcTypeMapper.jdbcTypeToString(newObject.getColumnType())};

    KeyHolder generatedKey = new GeneratedKeyHolder();
    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

      partitionDimension.getIndexUri(),
      JdbcTypeMapper.jdbcTypeToString(partitionDimension.getColumnType()),
      partitionDimension.getId()};

    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

      new ResourceDao(getDataSource()).delete(r);

    Object[] parameters;
    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

TOP

Related Classes of org.springframework.jdbc.core.PreparedStatementCreatorFactory

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.