| org.apache.cocoon.components.flow.javascript.ScriptableConnection
ScriptableConnection | public class ScriptableConnection extends ScriptableObject (Code) | | Wraps a JDBC connection and provides an API similar to JSTL
A ScriptableConnection provides two methods:
- query([String] stmt, [Array] parameters, [Number] startRow, [Number] maxRows, [Function] fun)
- update([String] stmt, [Array] parameters)
If the fun argument is provided to query it
will be called for each row returned (the row object will be passed as its
argument). For example:
var db = Database.getConnection(...);
var queryVal = ...;
var startRow = 0;
var maxRows = 100;
db.query("select * from table where column = ?",
[queryVal],
startRow,
maxRows,
function(row) {
print("column = " + row.column);
});
If fun is undefined, an object containing the following
properties will be returned instead:
- [Array] rows - an array of row objects
- [Array] rowsByIndex - An array with an array per row of column values
- [Array] columnNames - An array of column names
- [Number] rowCount - Number of rows returned
- [Boolean] limitedByMaxRows - true if not all rows are included due to matching a maximum value
A ScriptableConnection is also a wrapper around a real JDBC Connection and thus
provides all of methods of Connection as well
version: CVS $Id: ScriptableConnection.java 433543 2006-08-22 06:22:54Z crossley $ |
Method Summary | |
public static void | finishInit(Scriptable proto) | public Object | get(String name, Scriptable start) | public Object | get(int index, Scriptable start) | public String | getClassName() | public boolean | has(String name, Scriptable start) | public boolean | has(int index, Scriptable start) | public static Scriptable | jsConstructor(Context cx, Object[] args, Function ctorObj, boolean inNewExpr) | public Object | jsFunction_query(String sql, Object params, int startRow, int maxRows, Object funObj) | public int | jsFunction_update(String sql, Object params) | public void | put(String name, Scriptable start, Object value) | static Object | wrap(Scriptable wrapper, Scriptable wrapped, Object obj) | static Function | wrap(Scriptable wrapper, Scriptable wrapped, Function fun) |
wrapper | Scriptable wrapper(Code) | | |
ScriptableConnection | public ScriptableConnection()(Code) | | |
ScriptableConnection | public ScriptableConnection(Scriptable parent, Connection conn)(Code) | | |
finishInit | public static void finishInit(Scriptable proto)(Code) | | |
has | public boolean has(int index, Scriptable start)(Code) | | |
jsConstructor | public static Scriptable jsConstructor(Context cx, Object[] args, Function ctorObj, boolean inNewExpr) throws Exception(Code) | | |
jsFunction_update | public int jsFunction_update(String sql, Object params) throws JavaScriptException(Code) | | |
wrap | static Function wrap(Scriptable wrapper, Scriptable wrapped, Function fun)(Code) | | |
|
|