User Guide

282 Developing Web Applications with ColdFusion
Query Object
Provides an interface for working with ColdFusion queries, including methods for
retrieving name, row count, and column names as well as methods for getting and
setting data elements..
For detailed reference information on each of these interfaces see the Java CFX
Reference” on page 311.
Java CFX Class Loading
Each Java CFX class has its own associated ClassLoader which loads it and any
dependent classes also located in the
classes directory. When Java CFXs are reloaded
after a change, a new
ClassLoader is associated with the freshly loaded class. This
special behavior is similar to the way Java servlets are handled by the Java Web Server
and other servlet engines, and is required in order to implement automatic class
reloading.
However, this behavior can cause subtle problems when attempting to perform casts
on instances of classes loaded from a different
ClassLoader. The cast will fail even
though the objects are apparently of the same type. This is because the object was
created from a different ClassLoader and is therefore technically not of the same type.
To solve this problem, only perform casts to class or interface types that are loaded via
the standard Java class path, that is, classes not located in the classes directory. This
works because classes loaded from outside of the
classes directory are always loaded
using the system
ClassLoader and will therefore have a consistent runtime type.
Methods Used by Query Object
Method Description
getName
Retrieves the name of the query
getRowCount
Retrieves the number of rows in the query
getColumns
Retrieves the names of the query columns
getData
Retrieves a data element from the query
addRows
Adds a new row to the query
setData
Sets a data element within the query