Properties and methods of the helma.Database prototype.
To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Database.js')
To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Database.js')
Constructor for Database objects, providing access through relational
databases through JDBC. It is usually simpler to use one of the factory
methods {@link #createInstance} or {@link #getInstance}.
parameters
DbSource | source | instance of a helma.objectmodel.db.DbSource |
methods
- isOracle()
- isMySql()
- query(sql)
- execute(sql)
- getName()
Methods
Get the java.sql.Connection for this Database instance. This can be used
to operate on the connection directly, without going through the helma.Database
class.
returns
java.sql.Connection | the JDBC connection |
Returns the lower case name of the underlying database product.
returns
String | the name of the DB product |
Returns true if this is an Oracle database.
returns
boolean | true if this is an Oracle database. |
Returns true if this is a MySQL database.
returns
boolean | true if this is an MySQL database. |
Returns true if this is a PostgreSQL database.
returns
boolean | true if this is a PostgreSQL database. |
Executes the given SQL statement. The result set is returned
as JavaScript Array containing a JavaScript Object for each result.
parameters
String | sql | an SQL query statement |
returns
Array | an Array containing the result set |
Executes the given SQL statement, which may be an INSERT, UPDATE,
or DELETE statement or an SQL statement that returns nothing,
such as an SQL data definition statement. The return value is an integer that
indicates the number of rows that were affected by the statement.
parameters
String | sql | an SQL statement |
returns
int | either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing |
Return the name of the Helma DbSource object.
returns
String | the DbSource name |
Return the name of the JDBC driver used by this Database instance.
returns
String | the JDBC driver name |
Create a new Database instance using the given parameters.
Some of the parameters support shortcuts for known database products.
The url
parameter recognizes the values "mysql", "oracle" and
"postgresql". For those databases, it is also possible to pass just
hostname
or hostname:port
as url
parameters instead of the full JDBC URL.
parameters
String | driver | the class name of the JDBC driver. As shortcuts, the values "mysql", "oracle" and "postgresql" are recognized. |
String | url | the JDBC URL. |
String | name | the name of the database to use |
String | user | the the username |
String | password | the password |
returns
helma.Database | a helma.Database instance |
Get a Database instance using the Database source defined in the
application's db.properties file with the given name.
parameters
String | name | the name of the DB source as defined in db.properties |
returns
helma.Database | a helma.Database instance |