Provides database metadata and manages Myna.Table objects
| Myna. Database | Provides database metadata and manages Myna.Table objects |
| Functions and Properties | |
| Myna. Database | Construct a database proxy object |
| con | jdbc connection object. |
| init | (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. |
| dbType | Lowercase type of database. |
| 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. |
| getTable | returns a Myna.Table object representing the named table. |
| dbTypeToJs | 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) |
| getTablesBySchema | returns table information for a specific schema |
| _cacheKey | (private) cache key base for internal metadata caching |
| _getCache | (private) internal function for caching metadata |
| clearMetadataCache | clears metadata cache for this table |
Myna.Database = function ( ds )
Construct a database proxy object
| ds | String datsource name |
jdbc connection object. Created in init, closed on requestEnd See http://java.sun.com- /j2se- /1.4.2- /docs- /api- /java- /sql- /Connection.html
database matadata object. Created in init, closed on requestEnd. See http://java.sun.com- /j2se- /1.4.2- /docs- /api- /java- /sql- /DatabaseMetaData.html
array of table information for the current schema.
| table_cat | table catalog/db name (may be null) |
| table_schem | table schema/username (may be null) |
| table_name | table name |
| table_type | table type. Typical types are “TABLE”, “VIEW”, “SYSTEM TABLE”, “GLOBAL TEMPORARY”, “LOCAL TEMPORARY”, “ALIAS”, “SYNONYM”. |
| remarks | explanatory comment on the table |
| type_cat | the types catalog (may be null) |
| type_schem | the types schema (may be null) |
| type_name | type name (may be null) |
| self_referencing_col_name | name of the designated “identifier” column of a typed table (may be null) |
| ref_generation | specifies 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.
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)
| sourceType | DB column type as a string (“VARCHAR”) or number (112) |
Myna.Database.prototype.getTablesBySchema = function( schema )
returns table information for a specific schema
| schema | schema name to return tables for |
returns an array of table information for all schemas in the database
| table_cat | table catalog/db name (may be null) |
| table_schem | table schema/username (may be null) |
| table_name | table name |
| table_type | table type. Typical types are “TABLE”, “VIEW”, “SYSTEM TABLE”, “GLOBAL TEMPORARY”, “LOCAL TEMPORARY”, “ALIAS”, “SYNONYM”. |
| remarks | explanatory comment on the table |
| type_cat | the types catalog (may be null) |
| type_schem | the types schema (may be null) |
| type_name | type name (may be null) |
| self_referencing_col_name | name of the designated “identifier” column of a typed table (may be null) |
| ref_generation | specifies 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.
Myna.Database.prototype._getCache = function( type, f )
(private) internal function for caching metadata
Myna.Database.prototype.clearMetadataCache = function()
clears metadata cache for this table
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
Construct a database proxy object
Myna.Database = function ( ds )
(re)loads database metadata
Myna.Database.prototype.init = function()
returns a Myna.Table object representing the named table.
Myna.Database.prototype.getTable = function( tableName )
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.dbTypeToJs = function( sourceType )
returns table information for a specific schema
Myna.Database.prototype.getTablesBySchema = function( schema )
(private) internal function for caching metadata
Myna.Database.prototype._getCache = function( type, f )
clears metadata cache for this table
Myna.Database.prototype.clearMetadataCache = function()