Class NativeSql

java.lang.Object
org.mariadb.jdbc.util.NativeSql

public final class NativeSql extends Object
  • Constructor Details

    • NativeSql

      public NativeSql()
  • Method Details

    • parse

      public static String parse(String sql, Context context) throws SQLException
      Throws:
      SQLException
    • resolveEscapes

      private static String resolveEscapes(String escaped, Context context) throws SQLException
      Throws:
      SQLException
    • replaceFunctionParameter

      private static String replaceFunctionParameter(String functionString, Context context)
      Helper function to replace function parameters in escaped string. 3 functions are handles :
      • CONVERT(value, type): replacing SQL_XXX types to convertible type, i.e SQL_BIGINT to INTEGER
      • TIMESTAMPDIFF(type, ...): replacing type SQL_TSI_XXX in type with XXX, i.e SQL_TSI_HOUR with HOUR
      • TIMESTAMPADD(type, ...): replacing type SQL_TSI_XXX in type with XXX, i.e SQL_TSI_HOUR with HOUR

      caution: this use MariaDB server conversion: 'SELECT CONVERT('2147483648', INTEGER)' will return a BIGINT. MySQL will throw a syntax error.

      Parameters:
      functionString - input string
      Returns:
      unescaped string