javatools.db
Class DbDeleter

java.lang.Object
  |
  +--javatools.db.DbDeleter
Direct Known Subclasses:
DbReferencedDeleter

public class DbDeleter
extends java.lang.Object

A class used to delete records from SQL tables. The constructor is not public. To obtain a DbDeleter call DbTable.deleter(); Example: To delete all the people who are (younger than 18 or older than 80) and whose name is "Fred"...

 DbDatabase db = ...;
 DbTable people = db.getTable("PEOPLE");
 DbDeleter deleter = people.deleter();
 deleter.setWhere(people.getColumn("AGE").lessThan(new Integer(18)).or(
  people.getColumn("AGE").greaterThan(new Integer(80))).and(
  people.getColumn("NAME").equal("FRED"));
 int numberOfPeopleDeleted = deleter.execute();
 
This is equivilent to...
 DELETE FROM PEOPLE WHERE (AGE < 18 OR AGE > 80 ) AND NAME='Fred'
 
Note the use of equal(), NOT equals().


Method Summary
 int execute()
          Execute this command on the default connection.
 int execute(DbConnection dbcon)
          Execute this delete command on a specific connection.
 void setWhere(DbExpr where)
          Set the where condition for this delete operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setWhere

public void setWhere(DbExpr where)
Set the where condition for this delete operation.

Parameters:
where - The new where value

execute

public int execute(DbConnection dbcon)
            throws DbException
Execute this delete command on a specific connection.

Parameters:
dbcon - The connection to the database.
Returns:
The number of record affected.
Throws:
DbException - If something goes wrong.

execute

public int execute()
            throws DbException
Execute this command on the default connection.

Returns:
The number of record affected.
Throws:
DbException - Description of Exception