Myna. Database

Provides database metadata and manages Myna.Table objects

Summary
Myna. DatabaseProvides database metadata and manages Myna.Table objects
Functions and Properties
Myna. DatabaseConstruct a database proxy object
conjdbc connection object.
init(re)loads database metadata
dsDatasource associated with this Database object
isCaseSensitivetrue if table and column names are case sensitive
mddatabase matadata object.
dbTypeLowercase type of database.
schemasarray of schema names available in this datasource
defaultSchemaThe default schema for this datasource
tablesarray of table information for the current schema.
getTablereturns a Myna.Table object representing the named table.
dbTypeToJsStatic function that takes a column type name (“VARCHAR”) or a column type id (-5) and returns string that represents the equivalent Myna type (string, numeric, date, binary, unsupported)
getTablesBySchemareturns table information for a specific schema
_cacheKey(private) cache key base for internal metadata caching
_getCache(private) internal function for caching metadata
clearMetadataCacheclears metadata cache for this table

Functions and Properties

Myna. Database

Myna.Database = function (ds)

Construct a database proxy object

Parameters

dsString datsource name

con

jdbc connection object.  Created in init, closed on requestEnd See http://java.sun.com- /j2se- /1.4.2- /docs- /api- /java- /sql- /Connection.html

init

Myna.Database.prototype.init = function()

(re)loads database metadata

ds

Datasource associated with this Database object

isCaseSensitive

true if table and column names are case sensitive

md

database matadata object.  Created in init, closed on requestEnd.  See http://java.sun.com- /j2se- /1.4.2- /docs- /api- /java- /sql- /DatabaseMetaData.html

dbType

Lowercase type of database.  This should normaly be the name of the database vendor.

schemas

array of schema names available in this datasource

defaultSchema

The default schema for this datasource

tables

array of table information for the current schema.

Each element contains these properties

table_cattable catalog/db name (may be null)
table_schemtable schema/username (may be null)
table_nametable name
table_typetable type.  Typical types are “TABLE”, “VIEW”, “SYSTEM TABLE”, “GLOBAL TEMPORARY”, “LOCAL TEMPORARY”, “ALIAS”, “SYNONYM”.
remarksexplanatory comment on the table
type_catthe types catalog (may be null)
type_schemthe types schema (may be null)
type_nametype name (may be null)
self_referencing_col_namename of the designated “identifier” column of a typed table (may be null)
ref_generationspecifies how values in SELF_REFERENCING_COL_NAME are created.  Values are “SYSTEM”, “USER”, “DERIVED”.  (may be null)

Some databases may not return information for all tables.

getTable

Myna.Database.prototype.getTable = function(tableName)

returns a Myna.Table object representing the named table.

dbTypeToJs

Myna.Database.dbTypeToJs = function(sourceType)

Static function that takes a column type name (“VARCHAR”) or a column type id (-5) and returns string that represents the equivalent Myna type (string, numeric, date, binary, unsupported)

Parameters

sourceTypeDB column type as a string (“VARCHAR”) or number (112)

getTablesBySchema

Myna.Database.prototype.getTablesBySchema = function(schema)

returns table information for a specific schema

Parameters

schemaschema name to return tables for

Detail

returns an array of table information for all schemas in the database

Each element contains these properties

table_cattable catalog/db name (may be null)
table_schemtable schema/username (may be null)
table_nametable name
table_typetable type.  Typical types are “TABLE”, “VIEW”, “SYSTEM TABLE”, “GLOBAL TEMPORARY”, “LOCAL TEMPORARY”, “ALIAS”, “SYNONYM”.
remarksexplanatory comment on the table
type_catthe types catalog (may be null)
type_schemthe types schema (may be null)
type_nametype name (may be null)
self_referencing_col_namename of the designated “identifier” column of a typed table (may be null)
ref_generationspecifies how values in SELF_REFERENCING_COL_NAME are created.  Values are “SYSTEM”, “USER”, “DERIVED”.  (may be null)

Some databases may not return information for all tables.

_cacheKey

(private) cache key base for internal metadata caching

_getCache

Myna.Database.prototype._getCache = function(type,
f)

(private) internal function for caching metadata

clearMetadataCache

Myna.Database.prototype.clearMetadataCache = function()

clears metadata cache for this table

Detail

to improve performance, table metadata is cached between new Myna.Table calls.  After making changes to a table, a call to this function is necessary to refresh metadata.  This function is called automatically by all the Myna.Table functions that modify the table, so calling this should only be necessary if the table is modified outside of Myna.table or another Myna instance

Create modify and delete SQL tables
Myna.Database = function (ds)
Construct a database proxy object
Myna.Database.prototype.init = function()
(re)loads database metadata
Myna.Database.prototype.getTable = function(tableName)
returns a Myna.Table object representing the named table.
Myna.Database.dbTypeToJs = function(sourceType)
Static function that takes a column type name (“VARCHAR”) or a column type id (-5) and returns string that represents the equivalent Myna type (string, numeric, date, binary, unsupported)
Myna.Database.prototype.getTablesBySchema = function(schema)
returns table information for a specific schema
Myna.Database.prototype._getCache = function(type,
f)
(private) internal function for caching metadata
Myna.Database.prototype.clearMetadataCache = function()
clears metadata cache for this table