Libraries anvil sql

namespace sql
Provides access to relation databases through the JDBC interface.

Namespaces

namespace oracle
Oracle specific module for handling clobs (Character Long Objects). Reading from/writing to a Oracle clob is impossible using normal JDBC interfaces/classes (when using thin jdbc drivers). This module uses Oracle's own oracle.* classes to access clobs. You need to have classes12.zip (Oracle JDBC 2.0 drivers) in your classpath.


Classes

class Connection
extends anvil.lang.object
Database connection.

class MetaData
extends anvil.lang.object
Abstract base class for types having SQL meta data description available.

class ResultSet
extends anvil.sql.MetaData
Class reprsenting result of SQL query as a two dimensional table.

class Statement
extends anvil.sql.MetaData
JDBC prepared or callable statement.


Exceptions

class SQLError
extends anvil.lang.throwable


Constants

constant ARRAY

constant BIGINT

constant BINARY

constant BIT

constant BLOB

constant CHAR

constant CLOB

constant DATE

constant DECIMAL

constant DISTINCT

constant DOUBLE

constant FLOAT

constant INTEGER

constant JAVA_OBJECT

constant LONGVARBINARY

constant LONGVARCHAR

constant NULL

constant NUMERIC

constant OTHER

constant REAL

constant REF

constant SMALLINT

constant STRUCT

constant TIME

constant TIMESTAMP

constant TINYINT

constant VARBINARY

constant VARCHAR


Functions

Connection acquire(string poolName, [ boolean autoCommit, boolean readOnly ])
Acquires connection explicitly. 'poolName' has same rules as in query function.
Parameters poolName -  Name of connection pool, may contain database catalog
autoCommit -  auto commit
readOnly -  read only
Returns Acquired connection
Throws AcquireError -  If connection could not be retrieved
SQLError -  If SQL error occured

Connection connect(string url, string username, string password)
Creates connection to some database. Returned connection must be close with Connection.close method since connections returned are not pooled.
Throws SQLError -  If SQL error occured

object query(string poolName, string querystring, [ object parameters, ... ] )
Executes a query in a given connection which is acquired from configured pool named 'poolName'. 'poolName' may also contains database catalog, separated with colon from the name of pool. For instance, "mypool:mycatalog".

'querystring' is parsed so that given parameters are embedded to placeholders in string.

Placeholders:
? Embeds next parameter according to its type (i.e. strings are escaped and quoted)
$ Embeds next parameter as it is (result of tostring())
Parameters poolName -  Name of connection pool, may contain database catalog
querystring -  query string
parameters -  to be embedded
Returns null if error occurred, ResultSet if 'querystring' was an select query (or similar), otherwise returns update count as integer.
Throws AcquireError -  If connection could not be retrieved
SQLError -  If SQL error occured