Class QueryBinding

java.lang.Object
com.invirgance.convirgance.web.binding.QueryBinding
All Implemented Interfaces:
Binding

@Wiring public class QueryBinding extends Object implements Binding
For retrieving data from SQL database. QueryBinding executes parameterized SQL queries against a database and returns the results as JSON objects. It supports named parameter binding, allowing request parameters to be safely used in SQL statements.
Author:
jbanes
  • Constructor Details

    • QueryBinding

      public QueryBinding()
  • Method Details

    • getJndiName

      public String getJndiName()
      The JNDI name used to look up the database connection.

      This property must reference a valid JNDI resource that returns a DataSource.

      Returns:
      the JNDI name
    • setJndiName

      public void setJndiName(String jndiName)
      Sets the JNDI name for the data source lookup.
      Parameters:
      jndiName - The JDNI name.
    • getSql

      public String getSql()
      Returns the SQL query that will be executed.
      Returns:
      The SQL query.
    • setSql

      public void setSql(String sql)
      Sets the query used to retrieve data. Named bindings can be used. They will be bound by key to the parameters provided through getBinding(JSONObject).
      Parameters:
      sql - The new SQL query.
    • getBinding

      public Iterable<com.invirgance.convirgance.json.JSONObject> getBinding(com.invirgance.convirgance.json.JSONObject parameters)
      Executes the SQL query with the provided parameters. Parameter values are bound to named parameters in the SQL query.
      Specified by:
      getBinding in interface Binding
      Parameters:
      parameters - JSON object containing parameter names and values
      Returns:
      Query results as an iterable of JSONObjects