Default properties and methods of objects of the
class Packages.helma.scripting.rhino.extensions.DatabaseObject.
A DatabaseObject represents a connection to a relational database
and is created using the global getDBConnection function. There
is no constructor to instantiate these objects.
The Direct DB interface allows the developer to directly access relational databases defined in the db.properties file without going through the Helma object model layer.
The string passed to the getDBConnection function must match one of the data sources being defined in [AppDir]/db.properties, or an error will be thrown.
Example:
See also the documentation of the global getDBConnection() method.
The Direct DB interface allows the developer to directly access relational databases defined in the db.properties file without going through the Helma object model layer.
The string passed to the getDBConnection function must match one of the data sources being defined in [AppDir]/db.properties, or an error will be thrown.
Example:
var dbConnection = getDBConnection("db_source_name"); var dbRowset = dbConnection.executeRetrieval("select title from dummy"); while (dbRowset.next()) res.writeln(dbRowset.getColumnItem("title"));
var deletedRows = dbConnection.executeCommand("delete from foobar"); if(deletedRows){ res.writeln(deletedRows + " rows successfully deleted"); }
See also the documentation of the global getDBConnection() method.
see
Rowset object representing the results of a value
returning database query initiated using the
dbConnection.executeRetrieval method. There
is no constructor to instantiate these objects.
In addition, the RowSet will return any column name property as its value, any index as the value of the corresponding column, and enumerate column names. The enumeration will only contain the column names, not any property added to the prototype or the object itself. However the internal names (valueOf, toString, length), the properties of the prototype (including the routines of the RowSetAccessprotocol) takes precedence over the name of columns when accessed as a property. The usage of indexed access or of the routine getColumnItemis therefore prefered.
The RowSet string representation includes the SQL statement and its logical position if at start or at end.
In addition, the RowSet will return any column name property as its value, any index as the value of the corresponding column, and enumerate column names. The enumeration will only contain the column names, not any property added to the prototype or the object itself. However the internal names (valueOf, toString, length), the properties of the prototype (including the routines of the RowSetAccessprotocol) takes precedence over the name of columns when accessed as a property. The usage of indexed access or of the routine getColumnItemis therefore prefered.
The RowSet string representation includes the SQL statement and its logical position if at start or at end.
see
Methods
Return the last error which occured when connecting or
executing a statement, undefined if none.
returns
undefined if none |
Return the meta data attached to the connection.
Used to implement SELECT and other value returning statements.
Return a RowSet object implementing the RowsetAccess protocol if the request is successful. Returns false otherwise. Additional arguments are ignored, and data is always returned as a RowsetAccess. The cursor is positioned before the fist row. If false was returned, getLastError may be called on the database object to get the error information. Note that an error is generated (rather than returning a status) if the connection was not successful.
Return a RowSet object implementing the RowsetAccess protocol if the request is successful. Returns false otherwise. Additional arguments are ignored, and data is always returned as a RowsetAccess. The cursor is positioned before the fist row. If false was returned, getLastError may be called on the database object to get the error information. Note that an error is generated (rather than returning a status) if the connection was not successful.
parameters
String | sqlString | as String |
returns
DatabaseObject.RowSet with the resulting rowset, or false in case of error |
Used to implement INSERT, UPDATE, ddl statements and other
non value returning statements.
Returns the number of rows impacted if the request is successful. Returns false otherwise. If false was returned, getLastError may be called on the database object to get the error information. Note that an error is generated (rather than returning a status) if the connection was not successful.
Returns the number of rows impacted if the request is successful. Returns false otherwise. If false was returned, getLastError may be called on the database object to get the error information. Note that an error is generated (rather than returning a status) if the connection was not successful.
parameters
String | sqlString | as String |
returns
Number of rows impacted if successful or false if error. |
Get the next row of results, return true if there is a next row,
false otherwise. Note that next must be called before the first
row can be accesses.
returns
Boolean true if a next row exists else false |
Optimistic view of the possibility that more rows are present.
Currently only returns false if next returned false. It is possible to call this routine at any time.
Currently only returns false if next returned false. It is possible to call this routine at any time.
returns
Boolean false if calling next() returned false |
Return the last error which occured when connecting or executing a
statement, null (which test as false) if none.
returns
last error or else null if none |
Return the meta data attached to the row set.
Get the number of columns of this result, identical to
the length attribute. It is possible to call this
routine before the first record is fetched.
returns
Number of colums |
Get the name of a column, in a way which is always working.
The names can be accessed as properties, but they are shadowed
by the functions and properties of the RowSetAccess prototype object.
It is possible to call this routine before the first record is fetched.
returns
String containing the name of a column |
Get the number of the datatype associated with the column.
See the jdbc documentation for details. It is possible to
call this routine before the first record is fetched.
returns
Number of data-types associated with the column |
Get the name of the datatype associated with the column.
See the jdbc documentation for details. Some database do
not return a valid name, in that case undefined is returned.
It is possible to call this routine before the first record is fetched.
returns
String containing the name of the data-type associated with the column |
Get the value of a column by its name (the value can be accessed by
number simply indexing them - this is not faster than by name for FESI).
The proper value is returned even if the name is used for a property of
the RowSetAccess protocol, as next or length. A record must be available
(that is next must have been called at least once).
parameters
String | name | as String, name of the column |
returns
value of a column |