Class JdbcParameterUtils

java.lang.Object
org.springframework.batch.item.database.JdbcParameterUtils

public class JdbcParameterUtils extends Object
Helper methods for SQL statement parameter parsing. Only intended for internal use.
Since:
2.0
Author:
Thomas Risberg, Juergen Hoeller, Marten Deinum
  • Constructor Details

    • JdbcParameterUtils

      public JdbcParameterUtils()
  • Method Details

    • countParameterPlaceholders

      public static int countParameterPlaceholders(String sql, List<String> namedParameterHolder)
      Count the occurrences of the character placeholder in an SQL string sql. The character placeholder is not counted if it appears within a literal, that is, surrounded by single or double quotes. This method will count traditional placeholders in the form of a question mark ('?') as well as named parameters indicated with a leading ':' or '&'. The code for this method is taken from an early version of the NamedParameterUtils class. That method was later removed after some refactoring, but the code is useful here for the Spring Batch project. The code has been altered to better suite the batch processing requirements.
      Parameters:
      sql - String to search in. Returns 0 if the given String is null.
      namedParameterHolder - holder for the named parameters
      Returns:
      the number of named parameter placeholders