public class RDBMSTableUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
cleanupConnection(ResultSet rs,
Statement stmt,
Connection conn)
Method which can be used to clear up and ephemeral SQL connectivity artifacts.
|
static int |
enumerateUpdateSetEntries(Map<String,org.wso2.siddhi.core.util.collection.operator.CompiledExpression> updateSetExpressions,
PreparedStatement stmt,
Map<String,Object> updateSetMap) |
static String |
flattenAnnotatedElements(List<org.wso2.siddhi.query.api.annotation.Element> elements)
Util method used to convert a list of elements in an annotation to a comma-separated string.
|
static String |
formatQueryWithCondition(String query,
String condition)
Method for replacing the placeholder for conditions with the SQL Where clause and the actual condition.
|
static boolean |
isEmpty(String field)
Utility method which can be used to check if a given string instance is null or empty.
|
static RDBMSQueryConfigurationEntry |
lookupCurrentQueryConfigurationEntry(DataSource ds,
org.wso2.siddhi.core.util.config.ConfigReader configReader)
Isolates a particular RDBMS query configuration entry which matches the retrieved DB metadata.
|
static Map<String,Object> |
lookupDatabaseInfo(DataSource ds)
Utility method used for looking up DB metadata information from a given datasource.
|
static void |
populateStatementWithSingleElement(PreparedStatement stmt,
int ordinal,
org.wso2.siddhi.query.api.definition.Attribute.Type type,
Object value)
Util method which is used to populate a
PreparedStatement instance with a single element. |
static Map<String,String> |
processFieldLengths(String fieldInfo)
Read and return all string field lengths given in an RDBMS event table definition.
|
static List<String[]> |
processKeyValuePairs(String annotationString)
Converts a flat string of key/value pairs (e.g.
|
static void |
resolveCondition(PreparedStatement stmt,
RDBMSCompiledCondition compiledCondition,
Map<String,Object> conditionParameterMap,
int seed)
Util method used throughout the RDBMS Event Table implementation which accepts a compiled condition (from
compile-time) and uses values from the runtime to populate the given
PreparedStatement. |
static void |
rollbackConnection(Connection conn)
Method which is used to roll back a DB connection (e.g.
|
static void |
validateAnnotation(org.wso2.siddhi.query.api.annotation.Annotation annotation)
Util method which validates the elements from an annotation to verify that they comply to the accepted standards.
|
public static boolean isEmpty(String field)
field - the string instance to be checked.public static void cleanupConnection(ResultSet rs, Statement stmt, Connection conn)
rs - ResultSet instance (can be null)stmt - PreparedStatement instance (can be null)conn - Connection instance (can be null)public static void rollbackConnection(Connection conn)
conn - the Connection instance to be rolled back (can be null).public static void resolveCondition(PreparedStatement stmt, RDBMSCompiledCondition compiledCondition, Map<String,Object> conditionParameterMap, int seed) throws SQLException
PreparedStatement.stmt - the PreparedStatement instance which has already been build with '?'
parameters to be filled.compiledCondition - the compiled condition which was built during compile time and now is being provided
by the Siddhi runtime.conditionParameterMap - the map which contains the runtime value(s) for the condition.seed - the integer factor by which the ordinal count will be incremented when populating
the PreparedStatement.SQLException - in the unlikely case where there are errors when setting values to the statement
(e.g. type mismatches)public static int enumerateUpdateSetEntries(Map<String,org.wso2.siddhi.core.util.collection.operator.CompiledExpression> updateSetExpressions, PreparedStatement stmt, Map<String,Object> updateSetMap) throws SQLException
SQLExceptionpublic static void populateStatementWithSingleElement(PreparedStatement stmt, int ordinal, org.wso2.siddhi.query.api.definition.Attribute.Type type, Object value) throws SQLException
PreparedStatement instance with a single element.stmt - the statement to which the element should be set.ordinal - the ordinal of the element in the statement (its place in a potential list of places).type - the type of the element to be set, adheres to
Attribute.Type.value - the value of the element.SQLException - if there are issues when the element is being set.public static void validateAnnotation(org.wso2.siddhi.query.api.annotation.Annotation annotation)
annotation - the annotation to be validated.public static String flattenAnnotatedElements(List<org.wso2.siddhi.query.api.annotation.Element> elements)
elements - the list of annotation elements.public static Map<String,String> processFieldLengths(String fieldInfo)
fieldInfo - the field length annotation from the "@Store" definition (can be empty).public static List<String[]> processKeyValuePairs(String annotationString)
annotationString - the comma-separated string of key/value pairs.public static String formatQueryWithCondition(String query, String condition)
query - the SQL query in string format, with the "{{CONDITION}}" placeholder present.condition - the actual condition (originating from the ConditionVisitor).public static Map<String,Object> lookupDatabaseInfo(DataSource ds)
ds - the datasource from which the metadata needs to be looked up.public static RDBMSQueryConfigurationEntry lookupCurrentQueryConfigurationEntry(DataSource ds, org.wso2.siddhi.core.util.config.ConfigReader configReader) throws org.wso2.siddhi.core.exception.CannotLoadConfigurationException
ds - the datasource against which the entry should be matched.org.wso2.siddhi.core.exception.CannotLoadConfigurationException - if the configuration cannot be loaded.Copyright © 2017 WSO2. All rights reserved.