public class GenericSqlParser extends Object implements SqlParser
Modifier and Type | Class and Description |
---|---|
class |
GenericSqlParser.ParamsParser
The Class ParamsParser.
|
class |
GenericSqlParser.SplitParser
The Class SplitParser.
|
class |
GenericSqlParser.SqlTypeParser
The Class SqlTypeParser.
|
class |
GenericSqlParser.StripParser
The Class StripParser.
|
Constructor and Description |
---|
GenericSqlParser() |
Modifier and Type | Method and Description |
---|---|
Variable |
getVariable(String name,
Driver driver)
Creates a variable using given name and a driver.
|
boolean |
isCallable(String sql)
Checks if sql statement is callable.
|
String |
parseParams(String sql,
Map<String,Object> params,
Map<String,List<Integer>> paramMap,
List<String> outputParams,
Driver driver)
Parses the sql, updates params, paramMap and outputParams.
|
String |
removeChars(String sql)
Removes chars prohibited in the sql.
|
void |
setBindVariables(PreparedStatement st,
Map<String,Object> properties,
Map<String,List<Integer>> paramMap,
List<String> outpurParams,
Driver driver)
Sets the bind variables for the given prepared statement, including registering output parameters if any exist.
|
String |
setBindVariables(String sql,
Map<String,Object> properties)
Sets the bind variables using given properties.
|
String[] |
split(String sql)
Splits given sql on multiple sql statements using ";" as a separator.
|
String |
stripComments(String sql)
Strip comments.
|
public Variable getVariable(String name, Driver driver)
SqlParser
The expected format: out_type_name.
Examples:
out_number_abc
out_cursor_xyz
getVariable
in interface SqlParser
name
- the namedriver
- the driverpublic boolean isCallable(String sql)
SqlParser
isCallable
in interface SqlParser
sql
- the sqlpublic String parseParams(String sql, Map<String,Object> params, Map<String,List<Integer>> paramMap, List<String> outputParams, Driver driver)
SqlParser
parseParams
in interface SqlParser
sql
- the sqlparams
- the bind variables.paramMap
- the map containing bind variable name name as key and a list of parameter indexes as a value.
For example:
select * from abc where xyz = :xyz and mmm = :xyz
the map will contain "xyz" as a key and a list {1,2} as a value.
outputParams
- the output paramsdriver
- the driverpublic String removeChars(String sql)
SqlParser
removeChars
in interface SqlParser
sql
- the sqlpublic void setBindVariables(PreparedStatement st, Map<String,Object> properties, Map<String,List<Integer>> paramMap, List<String> outpurParams, Driver driver) throws Exception
SqlParser
setBindVariables
in interface SqlParser
st
- the prepared statementproperties
- the propertiesparamMap
- the map containing bind variable name name as key and a list of parameter indexes as a value.
For example:
select * from abc where xyz = :xyz and mmm = :xyz
the map will contain "xyz" as a key and a list {1,2} as a value.
outpurParams
- the list of output parameters, if any existdriver
- the driverException
- in case of any errorpublic String setBindVariables(String sql, Map<String,Object> properties)
SqlParser
setBindVariables
in interface SqlParser
sql
- the sqlproperties
- the propertiespublic String[] split(String sql)
SqlParser
public String stripComments(String sql)
SqlParser
stripComments
in interface SqlParser
sql
- the sqlCopyright © 2010-2020 Toolsverse. All Rights Reserved.