类 StatementUtil
java.lang.Object
com.databend.jdbc.StatementUtil
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明extractColumnTypes(String sql) This method is used to extract column types from a SQL statement.Extract the database name and the table name from the cleaned sql queryextractParamFromSetStatement(@NonNull String cleanSql, String sql) Extracts parameter from statement (eg: SET x=y)Returns the positions of the params markersstatic booleanReturns true if the statement is a query (eg: SELECT, SHOW).Parse sql statement to aRawStatementWrapper.Parse the sql statement to a list ofStatementInfoWrapperreplaceParameterMarksWithValues(@NonNull Map<Integer, String> params, @NonNull RawStatementWrapper rawStatement) Returns a list ofStatementInfoWrappercontaining sql statements constructed with theRawStatementWrapperand the parameters providedstatic List<StatementInfoWrapper> replaceParameterMarksWithValues(@NonNull Map<Integer, String> params, @NonNull String sql) Returns a list ofStatementInfoWrappercontaining sql statements constructed with the sql statement and the parameters provided
-
构造器详细资料
-
StatementUtil
public StatementUtil()
-
-
方法详细资料
-
isQuery
Returns true if the statement is a query (eg: SELECT, SHOW).- 参数:
cleanSql- the clean sql (sql statement without comments)- 返回:
- true if the statement is a query (eg: SELECT, SHOW).
-
extractParamFromSetStatement
public Optional<org.apache.commons.lang3.tuple.Pair<String,String>> extractParamFromSetStatement(@NonNull @NonNull String cleanSql, String sql) Extracts parameter from statement (eg: SET x=y)- 参数:
cleanSql- the clean version of the sql (sql statement without comments)sql- the sql statement- 返回:
- an optional parameter represented with a pair of key/value
-
extractColumnTypes
This method is used to extract column types from a SQL statement. It parses the SQL statement and finds the column types defined in the first pair of parentheses. The column types are then stored in a Map where the key is the index of the column in the SQL statement and the value is the type of the column.- 参数:
sql- The SQL statement from which to extract column types.- 返回:
- A Map where the key is the index of the column and the value is the type of the column.
-
parseToStatementInfoWrappers
Parse the sql statement to a list ofStatementInfoWrapper- 参数:
sql- the sql statement- 返回:
- a list of
StatementInfoWrapper
-
parseToRawStatementWrapper
Parse sql statement to aRawStatementWrapper. The method construct theRawStatementWrapperby splitting it in a list of sub-statements (supports multistatements)- 参数:
sql- the sql statement- 返回:
- a list of
StatementInfoWrapper
-
getParamMarketsPositions
Returns the positions of the params markers- 参数:
sql- the sql statement- 返回:
- the positions of the params markers
-
extractDbNameAndTableNamePairFromCleanQuery
public org.apache.commons.lang3.tuple.Pair<Optional<String>,Optional<String>> extractDbNameAndTableNamePairFromCleanQuery(String cleanSql) Extract the database name and the table name from the cleaned sql query- 参数:
cleanSql- the clean sql query- 返回:
- the database name and the table name from the sql query as a pair
-
replaceParameterMarksWithValues
public static List<StatementInfoWrapper> replaceParameterMarksWithValues(@NonNull @NonNull Map<Integer, String> params, @NonNull @NonNull String sql) Returns a list ofStatementInfoWrappercontaining sql statements constructed with the sql statement and the parameters provided- 参数:
params- the parameterssql- the sql statement- 返回:
- a list of sql statements containing the provided parameters
-
replaceParameterMarksWithValues
public List<StatementInfoWrapper> replaceParameterMarksWithValues(@NonNull @NonNull Map<Integer, String> params, @NonNull @NonNull RawStatementWrapper rawStatement) Returns a list ofStatementInfoWrappercontaining sql statements constructed with theRawStatementWrapperand the parameters provided- 参数:
params- the parametersrawStatement- the rawStatement- 返回:
- a list of sql statements containing the provided parameters
-