| Home >> All >> javatools >> [ db Javadoc ] |
| | javatools.db.util.* (9) | | javatools.db.xml.* (3) |
javatools.db: Javadoc index of package javatools.db.
Package Samples:
javatools.db.util
javatools.db.xml
Classes:
DbSelector: A class used to select tabular data from an SQL database. The constructor is not public. To obtain a DbSelector call DbDatabase.selector(); Example: To select FRED's record from the people table... DbDatabase db = ...; DbTable people = db.getTable("PEOPLE"); DbSelector selector = db.selector(); selector.addColumn(people.getColumn("NAME")); selector.addColumn(people.getColumn("AGE")); selector.setWhere(people.getColumn("NAME").equal("FRED")); DbTable result = selector.execute(); DbIterator it = result.iterator(); while (it.hasNextRow()) { DbRow row = it.nextRow(); System.out.println(row.getValue("NAME") ...
DbInserter: A class used to insert records into SQL tables. The constructor is not public. To obtain a DbInserter call DbTable.inserter(); Example: To insert a record into the people table... DbDatabase db = ...; DbTable people = db.getTable("PEOPLE"); DbInserter inserter = people.inserter(); inserter.addColumn(people.getColumn("NAME"), "Fred")); inserter.addColumn(people.getColumn("FAVOURITE_TEAM"), "Raiders"); inserter.addColumn(people.getColumn("AGE"), new Integer(30)); int numberOfPeopleInserted = inserter.execute(); This is equivilent to... INSERT INTO PEOPLE(NAME, FAVOURITE_TEAM, AGE) VALUES('Fred', ...
DbUpdater: A class used to update records from SQL tables. The constructor is not public. To obtain a DbUpdater call DbTable.updater(); Example: To update all the people who are (younger than 18 or older than 80) and whose name is "Fred"... to have a favourite_team of "Raiders"; DbDatabase db = ...; DbTable people = db.getTable("PEOPLE"); DbUpdater updater = people.deleter(); updater.addColumn(people.getColumn("FAVOURITE_TEAM"), "Raiders"); updater.setWhere(people.getColumn("AGE").lessThan(new Integer(18)).or( people.getColumn("AGE").greaterThan(new Integer(80))).and( people.getColumn("NAME").equal("FRED")); ...
DbDeleter: 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 ...
DbTrueExpr: An expression that always evaluates to true. If not optimised away but DbAndExpr, this will probably result in "0 = 0" in the SQL. The use of true expressions makes it very convenient for dynamically generated queries... DbExpr e = db.trueExpr(); if (name != null) { e = e.and(table.getColumn("NAME")).equals(name)); } if (age != null) { e = e.and(table.getColumn("AGE")).equals(age)); } This gets converted to... (0 = 0) AND ( NAME = ? ) AND ( AGE = ? ) and then DbAndExpr optimises this to... ( NAME = ? ) AND ( AGE = ? )
DbFalseExpr: An expression that always evaluates to false. If not optimised away by DbTrueExpr, it will probably result in "0 = 1" in the SQL. The use of false expressions makes it very convenient for dynamically generated queries... DbExpr e = db.falseExpr(); if (name != null) { e = e.or(table.getColumn("NAME")).equals(name)); } if (age != null) { e = e.or(table.getColumn("AGE")).equals(age)); } This gets converted to... (0 = 1) OR ( NAME = ? ) OR ( AGE = ? ) and then DbOrExpr optimises this to... ( NAME = ? ) OR ( AGE = ? )
DbOrExpr: An expression of the form A OR B. The reason we have this class as well as DbCriterion, is that this class will optimise away unnecessary segments. i.e. A OR FALSE will be optimised to just A. The reason you may find a FALSE expression in your code is the use of DbDatabase.falseExpr(). This is a very convenient thing for dynamically generated queries. Of course we could just leave the dummy false expressions in the final SQL and presumably the dbms can optimise it away fine, but it looks a bit ugly and nasty to have these dummy expressions in the result.
DbAndExpr: An expression of the form A AND B. The reason we have this class as well as DbCriterion, is that this class will optimise away unnecessary segments. i.e. A AND TRUE will be optimised to just A. The reason you may find a TRUE expression in your code is the use of DbDatabase.trueExpr(). Of course we could just leave the dummy true expressions in the final SQL and presumably the dbms can optimise it away fine, but it looks a bit ugly and nasty to have these dummy expressions in the result.
DbParenthesis: This expression has the result of putting parenthesis around another expression. i.e. "expr" becomes "( expr )". It should be noted that you won't usually use this class in your application code. Normally the order of evaluation of the SQL is implied by the parethesis in your Java code. i.e. DbExpr x = a.and((b.or(c)).and(d)) This will automatically retain the Java evaluation order... A AND ( (B OR C) AND D)
DbRow: A row of tabular data. This class can return fields in different formats. Care should be taken not to ask for a field in an inappropriate format. e.g. don't ask for a field of letters as a number. TODO: More conversions can probably be done. e.g. convert varchar fields made of numbers into integers etc.
DbConstraint: This abstract class represents a generic set of constraints for a table. It contains a lot of code already written for generic purposes, i.e. it can be derived with few code. If you want to add additional checks, you can easily add your own code, rewriting check and update methods.
DbTableIterator: An iterator class for DbTables. There is no public constructor. Use DbTable.iterator(). While this class supports the java.util.Iterator interface, it is recommended not to use it because they do not throw the proper DbException on error. Instead use the similar hasNextRow() and nextRow().
DbOrderBy: A class that represents an ORDER BY clause in a SELECT. An order by clause consists of a column and an optional DESC descending clause. Usually this class will not be referred to directly in an application. More usually you will use DbSelector.addOrderBy().
AbstractTable: A class representing tabular data. Could be a real database table or the result of a SELECT. Based upon class DbTable written by Chris Bitmead, of which it is an abstraction to differentiate between real tables and results of a SELECT command.
DbDatabase: A class that represents a particular database. A DbDatabase basically consists of some connection parameters plus we keep track of the open connections. The constructor is not public. Use DbManager.getDatabase().
DbManager: A class to manage all the other DbDatabases. Usually there will be only one DbManager object, thus you should use singleton() to access it. e.g. DbDatabase db = DbManager.singleton().getDatabase("foo");
JCrypt: JCrypt.java Java-based implementation of the unix crypt command Based upon C source code written by Eric Young, eay@psych.uq.oz.au
DbCachedTable: It's a "cached" table, that represents a result from SELECT in a cached way, that is it can be accessed more than once.
DbLiteral: Inserts a piece of literal text within the SQL expression. This can be useful for non-portable hacks into the SQL code.
DbMiscExpr: An SQL expression of the form FUNCNAME(parameter....). (Hey Chris what's the difference between this and DbFuncExpr???)
DbColumn: A class that represents a particular column within a particular DbTable. Based upon class DbColumn by Chris Bitmead.
DbReferencedTable: It is currently a hybrid. It should be rewritten. At present time, it has been surclassed by DbAbstractTable.
DbDynamicConstraint: It is a class representing a "dynamic" constraint, i.e. a constraint that changes references dynamically.
DbFixedAbstractTable: It represents a real database table. It's a base class to build derived classes representing real tables.
DbCriterion: It is a class that represents an expression of the type "A op B", where "op" is a generic operator.
| Home | Contact Us | Privacy Policy | Terms of Service |