HiRISE

HiRISE.HiReport.sql
Class Select

java.lang.Object
  extended by HiRISE.HiReport.sql.SQL
      extended by HiRISE.HiReport.sql.Select

public class Select
extends SQL

This class will build a SQL select statement of arbitrary complexity and contains a query method for binding constrained values and returning a result set.


Nested Class Summary
 
Nested classes/interfaces inherited from class HiRISE.HiReport.sql.SQL
SQL.Order
 
Field Summary
protected  ResultSet rs
          stores results
 
Constructor Summary
Select(Column... columns)
          Create a new select for the given columns.
Select(Column[] columns, boolean distinct)
          Create a new select for the given columns.
Select(Set<Column> columns)
          Create a new select with a collection of columns
 
Method Summary
 Select and(Column c, Constraint constraint)
          Add to the where clause
 Select and(Constraint constraint)
          Add to the where clause
 void close()
          Close the statement.
 Select from(Table table)
          Add a 'from table' clause.
 Select join(Table table)
          Create an ordinary join on another table
 Select leftjoin(Table table)
          Create a left join on another table
 Select limit(int limit)
          Add a limit clause
 Select limit(int limit, int offset)
          Add a limit clause
 Select on(Column c, Constraint constraint)
          Add an on clause following a join
 Select or(Column c, Constraint constraint)
          Add to the where clause
 Select or(Constraint constraint)
          Add to the where clause
 Select orderby(Column... columns)
          Add an order by clause
 Select orderby(Column c)
          Add an order by clause
 Select orderby(Column c, SQL.Order order)
          Add an order by clause
 Select orderby(String by, SQL.Order order)
          Add an order by clause
 ResultSet query(Connection conn)
          Binds the constrained variables, executes the query and returns a reference to the result.
 ResultSet query(Connection conn, boolean streaming)
          Binds the constrained variables, executes the query and returns a reference to the result.
 String toString()
           
 Select union(Column... cols)
          Construct a union select
 Select union(Column[] cols, boolean distinct)
          Construct a union to this select
 Select union(Set<Column> cols)
          Construct a union select
 Select where(Column c, Constraint constraint)
          Start a where clause
 
Methods inherited from class HiRISE.HiReport.sql.SQL
bind, get, getDate, getDouble, getFloat, getInt, getInteger, getLong, getShort, getString, getTimestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rs

protected transient ResultSet rs
stores results

Constructor Detail

Select

public Select(Column... columns)
Create a new select for the given columns.

Parameters:
columns - Columns to return in query

Select

public Select(Set<Column> columns)
Create a new select with a collection of columns

Parameters:
columns - Columns to return in query

Select

public Select(Column[] columns,
              boolean distinct)
Create a new select for the given columns.

Parameters:
columns - Columns to return
distinct - True if distinct
Method Detail

union

public Select union(Column... cols)
Construct a union select

Parameters:
cols - list of columns
Returns:
this select

union

public Select union(Set<Column> cols)
Construct a union select

Parameters:
cols - list of columns
Returns:
this select

union

public Select union(Column[] cols,
                    boolean distinct)
Construct a union to this select

Parameters:
cols - list of columns
distinct - true for distinct
Returns:
this select

from

public Select from(Table table)
Add a 'from table' clause.

Parameters:
table - Instance of table
Returns:
the select object

join

public Select join(Table table)
Create an ordinary join on another table

Parameters:
table - the table to join
Returns:
the select

leftjoin

public Select leftjoin(Table table)
Create a left join on another table

Parameters:
table - the table to join
Returns:
the select

on

public Select on(Column c,
                 Constraint constraint)
Add an on clause following a join

Parameters:
c - the column to join on
constraint - how to constrain the join
Returns:
the select

where

public Select where(Column c,
                    Constraint constraint)
Start a where clause

Parameters:
c - the column to join on
constraint - how to constrain the join
Returns:
the select

and

public Select and(Column c,
                  Constraint constraint)
Add to the where clause

Parameters:
c - the column to join on
constraint - how to constrain the column
Returns:
the select

and

public Select and(Constraint constraint)
Add to the where clause

Parameters:
constraint - what to constrain
Returns:
the select

or

public Select or(Column c,
                 Constraint constraint)
Add to the where clause

Parameters:
c - the column to join on
constraint - how to constrain the column
Returns:
the select

or

public Select or(Constraint constraint)
Add to the where clause

Parameters:
constraint - what to constrain
Returns:
the select

orderby

public Select orderby(Column c)
Add an order by clause

Parameters:
c - column to order on
Returns:
the select

orderby

public Select orderby(Column c,
                      SQL.Order order)
Add an order by clause

Parameters:
c - column to order on
order - specify the order
Returns:
the select

orderby

public Select orderby(String by,
                      SQL.Order order)
Add an order by clause

Parameters:
by - the field
order - the sort order
Returns:
the select

orderby

public Select orderby(Column... columns)
Add an order by clause

Parameters:
columns - column to order on
Returns:
the select

limit

public Select limit(int limit)
Add a limit clause

Parameters:
limit - number or rows
Returns:
the select

limit

public Select limit(int limit,
                    int offset)
Add a limit clause

Parameters:
limit - number or rows
offset - row offset from zero
Returns:
the select

toString

public String toString()
Overrides:
toString in class Object

query

public ResultSet query(Connection conn,
                       boolean streaming)
                throws SQLException
Binds the constrained variables, executes the query and returns a reference to the result.

Parameters:
conn - Connection to use
streaming - if true, attempt to set streaming of resultset
Returns:
number of rows
Throws:
SQLException - Query failed

query

public ResultSet query(Connection conn)
                throws SQLException
Binds the constrained variables, executes the query and returns a reference to the result.

Parameters:
conn - Connection to use
Returns:
number of rows
Throws:
SQLException - Query failed

close

public void close()
           throws SQLException
Close the statement.

Throws:
SQLException - Failed to close statement

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona