|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mortbay.JDBC.Clause | +--com.mortbay.JDBC.Select
Select produces SQL SELECT statements.
Most of the clauses of a SELECT statement are supported, including SELECT DISTINCT, FROM, WHERE, ORDER BY. The WHERE subclauses can use either columns or values as the right hand side of expressions.
This class DOES NOT check the grammatical accuracy of the SQL statement produced.
s = new Select(); s.select(UserTable, NameColumn) .from(UserTable) .where(UserTable, AgeColumn, Select.GREATER_THAN, new Integer(30)) .and() .where(UserTable,AgeColumn, Select.LESS_THAN, new Integer(50)); Enumeration results = statement.query(db); while (answer.hasMoreElements()) { Vector row = (Vector)answer.nextElement()); String name = (String)row.firstElement(); }
Clause
Field Summary | |
static java.lang.String |
__SEPARATOR
|
static java.lang.String |
AND
|
static int |
DESC
for ORDER BY clause |
static boolean |
DISTINCT
indicates if this select should use DISTINCT keyword |
static java.lang.String |
EQUALS
|
static java.lang.String |
GREATER_THAN
|
static java.lang.String |
LESS_THAN
|
static java.lang.String |
LIKE
|
static java.lang.String |
NOT_EQUALS
ANSI SQL standard operators and keywords |
static java.lang.String |
OR
|
Constructor Summary | |
Select()
Constructor. |
|
Select(boolean distinct)
Constructor. |
Method Summary | |
Select |
from(Table table)
Add a table name to the FROM clause |
static void |
main(java.lang.String[] args)
main |
Select |
orderBy(Table table,
Column column)
Specify a column whose values should select the order of the results. |
Select |
orderSequence(int descending)
ORDER DESCENDING, rather than ASCENDING |
static java.lang.String |
qualifyName(Table table,
Column column)
Build a fully qualified name of the form: table.column |
java.util.Enumeration |
query(Database db)
Build the query out of all of the clauses that have been established, and do it against the database |
Select |
select(Table table)
Like SELECT *, but the actual column names are inserted. |
Select |
select(Table table,
Column col)
Add a subclause to the SELECT clause |
static void |
test(Database db)
test |
java.lang.String |
toString()
|
Methods inherited from class com.mortbay.JDBC.Clause |
and,
close,
open,
or,
where,
where,
where,
where |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final boolean DISTINCT
public static final int DESC
public static final java.lang.String NOT_EQUALS
public static final java.lang.String EQUALS
public static final java.lang.String LESS_THAN
public static final java.lang.String GREATER_THAN
public static final java.lang.String AND
public static final java.lang.String OR
public static final java.lang.String LIKE
public static final java.lang.String __SEPARATOR
Constructor Detail |
public Select(boolean distinct)
name
- - name for the querypublic Select()
Method Detail |
public Select select(Table table, Column col)
table
- col
- public Select select(Table table)
table
- public Select from(Table table)
table
- public Select orderBy(Table table, Column column)
table
- column
- public Select orderSequence(int descending)
descending
- public java.util.Enumeration query(Database db) throws java.sql.SQLException
db
- public java.lang.String toString()
public static java.lang.String qualifyName(Table table, Column column)
table
- column
- public static void test(Database db)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |