Class DBQuery
java.lang.Object
com.inductiveautomation.ignition.gateway.datasource.query.DBQuery
A class that helps construct a dynamic SQL SELECT query, using proper quoting syntax and
 prepared-statement style parameters. Use by creating a DBQuery, adding return columns, where
 clauses, etc. When finished, you can either retrieve the SQL and params and execute manually, or
 use one of the execute functions.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic interfaceA clause that requires parameters to be added to the prepared statementstatic interfacestatic classstatic classstatic classstatic interfacestatic interfaceAn arbitrary part of a SQL query, that knows how to append itself into a larger query.static interface
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final DBQuery.RowToObject<Integer>Pulls the first column out of each row as an integerstatic final DBQuery.RowToObject<String>Pulls the first column out of each row as a string
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddGroupBy(String column) addOrderBy(String column, boolean ascending) addOrWhereClause(DBQuery.Clause... clauses) addReturnColumn(String column, SQLType type) com.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorexecute(Connection con) Execute the query represented by this DBQuery, returning a list of rows.execute(Connection con, boolean closeConnectionAfter) Execute the query represented by this DBQuery, returning a list of rows.<T> List<T>execute(Connection con, boolean closeConnectionAfter, DBQuery.RowToObject<T> handler) voidexecute(Connection con, boolean closeConnectionAfter, DBQuery.StreamingHandler handler) Executes the query represented by this DBQuery, calling the streaming handler'sDBQuery.StreamingHandler.onRow(int, ResultSet)function on every row returned be the ResultSet.voidexecute(Connection con, DBQuery.StreamingHandler handler) Executes the query represented by this DBQuery, calling the streaming handler'sDBQuery.StreamingHandler.onRow(int, ResultSet)function on every row returned be the ResultSet.com.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.OperatorgetSql()com.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operatorcom.inductiveautomation.ignition.gateway.datasource.query.DBQuery.OperatorsetCurrentTableAlias(String value) Sets the alias that will be used by subsequent calls to functions that add column based elements.
- 
Field Details- 
TO_STRINGPulls the first column out of each row as a string
- 
TO_INTPulls the first column out of each row as an integer
 
- 
- 
Constructor Details- 
DBQueryCreate a new query- Parameters:
- q- The column quote character
 
- 
DBQuery
 
- 
- 
Method Details- 
getQuoteChar
- 
setCurrentTableAliasSets the alias that will be used by subsequent calls to functions that add column based elements. For example, if you wanted to select columns from multiple tables, you would do:
 - setCurrentTableAlias("a")
- addReturnColumn(...)
- setCurrentTableAlias("b")
- addReturnColumn(...)
 
- 
executeExecute the query represented by this DBQuery, returning a list of rows. Individual columns will be read per theSQLTypespecified inaddReturnColumn(String, SQLType), which can prevent some auto-coercion issues if JDBC drivers implementResultSet.getObject(int)in an unusual way. Closes the connection provided automatically after executing the query.- Parameters:
- con- The connection to use.
- Returns:
- A list of lists of rows. Each inner list will have as many elements as columns have been specified on the query.
- Throws:
- SQLException
 
- 
executeExecute the query represented by this DBQuery, returning a list of rows. Individual columns will be read per theSQLTypespecified inaddReturnColumn(String, SQLType), which can prevent some auto-coercion issues if JDBC drivers implementResultSet.getObject(int)in an unusual way.- Parameters:
- con- The connection to use.
- closeConnectionAfter- Whether to close the connection after the query has been executed.
- Returns:
- A list of lists of rows. Each inner list will have as many elements as columns have been specified on the query.
- Throws:
- SQLException
 
- 
executeExecutes the query represented by this DBQuery, calling the streaming handler'sDBQuery.StreamingHandler.onRow(int, ResultSet)function on every row returned be the ResultSet. Closes the connection afterwards.- Throws:
- SQLException
 
- 
executepublic void execute(Connection con, boolean closeConnectionAfter, DBQuery.StreamingHandler handler) throws SQLException Executes the query represented by this DBQuery, calling the streaming handler'sDBQuery.StreamingHandler.onRow(int, ResultSet)function on every row returned be the ResultSet.- Parameters:
- closeConnectionAfter- Whether to close the provided connection after executing the query.
- Throws:
- SQLException
 
- 
executepublic <T> List<T> execute(Connection con, boolean closeConnectionAfter, DBQuery.RowToObject<T> handler) throws SQLException - Throws:
- SQLException
 
- 
addReturnColumn
- 
addTable
- 
addTableJoin
- 
addWhereClause
- 
getWhereClauses
- 
addOrWhereClause
- 
addGroupBy
- 
addOrderBy
- 
equal
- 
equal
- 
notequal
- 
notequal
- 
gt
- 
gt
- 
ge
- 
ge
- 
lt
- 
lt
- 
le
- 
le
- 
hasFlag
- 
hasFlag
- 
notFlag
- 
notFlag
- 
like
- 
like
- 
isnullpublic com.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operator isnull(String column) 
- 
isnotnullpublic com.inductiveautomation.ignition.gateway.datasource.query.DBQuery.Operator isnotnull(String column) 
- 
getSql
- 
getParams
 
-