UNPKG

jdbc

Version:

Node Module JDBC wrapper

1,295 lines (1,193 loc) 107 kB
/* jshint node: true */ "use strict"; var _ = require('lodash'); var ResultSet = require('./resultset'); var Connection = require('./connection'); var jinst = require('./jinst'); var java = jinst.getInstance(); function DatabaseMetaData(dbm) { this._dbm = dbm; } /** * Retrieves the schema names available in this database. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {Function} callback * @returns {ResultSet} Via callback: a ResultSet object in which each row is a schema description */ DatabaseMetaData.prototype.getSchemas = function(catalog, schemaPattern, callback) { if(_.isFunction(catalog)) { callback = catalog; catalog = null; } else if(_.isFunction(schemaPattern)) { callback = schemaPattern; schemaPattern = null; } var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getSchemas(catalog, schemaPattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves a description of the tables available in the given catalog. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} tableNamePattern - A table name pattern; must match the table name as it is stored in the database * @param {String[]} types - A list of table types, which must be from the list of table types returned from getTableTypes(),to include; null returns all types * @param {Function} callback * @returns {ResultSet} Via callback: each row is a table description */ DatabaseMetaData.prototype.getTables = function(catalog, schemaPattern, tableNamePattern, types, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) && (_.isNull(tableNamePattern) || _.isUndefined(tableNamePattern) || _.isString(tableNamePattern)) && (_.isNull(types) || _.isUndefined(types) || _.isArray(types)) ); if(_.isArray(types)) { _.forEach(types, function(type) { if(_.isString(type)) return; validParams = false; return false; }); } if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getTables(catalog, schemaPattern, tableNamePattern, types, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves whether the current user can call all the procedures returned by * the method getProcedures. * * @param {Function} callback * @returns {Boolean} Via callback: true if so; false otherwise */ DatabaseMetaData.prototype.allProceduresAreCallable = function(callback) { this._dbm.allProceduresAreCallable(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves whether the current user can use all the tables returned by the * method getTables in a SELECT statement. * * @param {Function} callback * @returns {Boolean} Via callback: true if so; false otherwise */ DatabaseMetaData.prototype.allTablesAreSelectable = function(callback) { this._dbm.allTablesAreSelectable(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves whether a SQLException while autoCommit is true inidcates that all * open ResultSets are closed, even ones that are holdable. * * @param {Function} callback * @returns {Boolean} Via callback: true if so; false otherwise */ DatabaseMetaData.prototype.autoCommitFailureClosesAllResultSets = function(callback) { this._dbm.autoCommitFailureClosesAllResultSets(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves whether a data definition statement within a transaction forces * the transaction to commit. * * @param {Function} callback * @returns {Boolean} Via callback: true if so; false otherwise */ DatabaseMetaData.prototype.dataDefinitionCausesTransactionCommit = function(callback) { this._dbm.dataDefinitionCausesTransactionCommit(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves whether this database ignores a data definition statement within a * transaction. * * @param {Function} callback * @returns {Boolean} Via callback: true if so; false otherwise */ DatabaseMetaData.prototype.dataDefinitionIgnoredInTransactions = function(callback) { this._dbm.dataDefinitionIgnoredInTransactions(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves whether or not a visible row delete can be detected by calling the * method ResultSet.rowDeleted. * * @param {Number} type - the ResultSet type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE * @param {Function} callback * @returns {Boolean} Via callback: true if deletes are detected by the given result set type; false otherwise */ DatabaseMetaData.prototype.deletesAreDetected = function(type, callback) { var validParams = _.isInteger(type); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.deletesAreDetected(type, function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves whether the return value for the method getMaxRowSize includes the * SQL data types LONGVARCHAR and LONGVARBINARY. * * @param {Function} callback * @returns {Boolean} Via callback: true if so; false otherwise */ DatabaseMetaData.prototype.doesMaxRowSizeIncludeBlobs = function(callback) { this._dbm.doesMaxRowSizeIncludeBlobs(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves whether a generated key will always be returned if the column * name(s) or index(es) specified for the auto generated key column(s) are * valid and the statement succeeds. * * @param {Function} callback * @returns {Boolean} Via callback: true if so; false otherwise */ DatabaseMetaData.prototype.generatedKeyAlwaysReturned = function(callback) { this._dbm.generatedKeyAlwaysReturned(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves a description of the given attribute of the given type for a * user-defined type (UDT) that is available in the given schema and catalog. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} typeNamePattern - A type name pattern; must match the type name as it is stored in the database * @param {String} attributeNamePattern - An attribute name pattern; must match the attribute name as it is declared in the database * @param {Function} callback * @returns {ResultSet} Via callback: a ResultSet object in which each row is an attribute description */ DatabaseMetaData.prototype.getAttributes = function(catalog, schemaPattern, typeNamePattern, attributeNamePattern, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) && (_.isNull(typeNamePattern) || _.isUndefined(typeNamePattern) || _.isString(typeNamePattern)) && (_.isNull(attributeNamePattern) || _.isUndefined(attributeNamePattern) || _.isString(attributeNamePattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getAttributes(catalog, schemaPattern, typeNamePattern, attributeNamePattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves a description of a table's optimal set of columns that uniquely * identifies a row. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schema - A schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} table - A table name; must match the table name as it is stored in the database * @param {Number} scope - The scope of interest; use same values as SCOPE * @param {Boolean} nullable - Include columns that are nullable * @param {Function} callback * @returns {ResultSet} Via callback: each row is a column description */ DatabaseMetaData.prototype.getBestRowIdentifier = function(catalog, schema, table, scope, nullable, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schema) || _.isUndefined(schema) || _.isString(schema)) && _.isString(table) && _.isInteger(scope) && _.isBoolean(nullable) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getBestRowIdentifier(catalog, schema, table, scope, nullable, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves the catalog names available in this database. * * @param {Function} callback * @returns {ResultSet} Via callback: a ResultSet object in which each row has a single String column that is a catalog name */ DatabaseMetaData.prototype.getCatalogs = function(callback) { this._dbm.getCatalogs(function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves the String that this database uses as the separator between a * catalog and table name. * * @param {Function} callback * @returns {String} Via callback: the separator string */ DatabaseMetaData.prototype.getCatalogSeparator = function(callback) { this._dbm.getCatalogSeparator(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the database vendor's preferred term for "catalog". * * @param {Function} callback * @returns {String} Via callback: the vendor term for "catalog" */ DatabaseMetaData.prototype.getCatalogTerm = function(callback) { this._dbm.getCatalogTerm(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves a list of the client info properties that the driver supports. * * @param {Function} callback * @returns {ResultSet} Via callback: A ResultSet object; each row is a supported client info property */ DatabaseMetaData.prototype.getClientInfoProperties = function(callback) { this._dbm.getClientInfoProperties(function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves a description of the access rights for a table's columns. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schema - A schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} table - A table name; must match the table name as it is stored in the database * @param {String} columnNamePattern - A column name pattern; must match the column name as it is stored in the database * @param {Function} callback * @returns {ResultSet} Via callback: each row is a column privilege description */ DatabaseMetaData.prototype.getColumnPrivileges = function(catalog, schema, table, columnNamePattern, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schema) || _.isUndefined(schema) || _.isString(schema)) && _.isString(table) && (_.isNull(columnNamePattern) || _.isUndefined(columnNamePattern) || _.isString(columnNamePattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getColumnPrivileges(catalog, schema, table, columnNamePattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves a description of table columns available in the specified catalog. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} tableNamePattern - A table name pattern; must match the table name as it is stored in the database * @param {String} columnNamePattern - A column name pattern; must match the column name as it is stored in the database * @param {Function} callback * @returns {ResultSet} Via callback: each row is a column description */ DatabaseMetaData.prototype.getColumns = function(catalog, schemaPattern, tableNamePattern, columnNamePattern, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) && (_.isNull(tableNamePattern) || _.isUndefined(tableNamePattern) || _.isString(tableNamePattern)) && (_.isNull(columnNamePattern) || _.isUndefined(columnNamePattern) || _.isString(columnNamePattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves the connection that produced this metadata object. * * @param {Function} callback * @returns {Connection} Via callback: the connection that produced this metadata object */ DatabaseMetaData.prototype.getConnection = function(callback) { this._dbm.getConnection(function(err, result) { if (err) { return callback(err); } return callback(null, new Connection(result)); }); }; /** * Retrieves a description of the foreign key columns in the given foreign key * table that reference the primary key or the columns representing a unique * constraint of the parent table (could be the same or a different table). * * @param {String} parentCatalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means drop catalog name from the selection criteria * @param {String} parentSchema - A schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means drop schema name from the selection criteria * @param {String} parentTable - The name of the table that exports the key; must match the table name as it is stored in the database * @param {String} foreignCatalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means drop catalog name from the selection criteria * @param {String} foreignSchema - A schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means drop schema name from the selection criteria * @param {String} foreignTable - The name of the table that imports the key; must match the table name as it is stored in the database * @param {Function} callback * @returns {ResultSet} Via callback: each row is a foreign key column description */ DatabaseMetaData.prototype.getCrossReference = function(parentCatalog, parentSchema, parentTable, foreignCatalog, foreignSchema, foreignTable, callback) { var validParams = ( (_.isNull(parentCatalog) || _.isUndefined(parentCatalog) || _.isString(parentCatalog)) && (_.isNull(parentSchema) || _.isUndefined(parentSchema) || _.isString(parentSchema)) && _.isString(parentTable) && (_.isNull(foreignCatalog) || _.isUndefined(foreignCatalog) || _.isString(foreignCatalog)) && (_.isNull(foreignSchema) || _.isUndefined(foreignSchema) || _.isString(foreignSchema)) && _.isString(foreignTable) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getCrossReference(parentCatalog, parentSchema, parentTable, foreignCatalog, foreignSchema, foreignTable, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves the major version number of the underlying database. * * @param {Function} callback * @returns {Number} Via callback: the underlying database's major version */ DatabaseMetaData.prototype.getDatabaseMajorVersion = function(callback) { this._dbm.getDatabaseMajorVersion(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the minor version number of the underlying database. * * @param {Function} callback * @returns {Number} Via callback: underlying database's minor version */ DatabaseMetaData.prototype.getDatabaseMinorVersion = function(callback) { this._dbm.getDatabaseMinorVersion(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the name of this database product. * * @param {Function} callback * @returns {String} Via callback: database product name */ DatabaseMetaData.prototype.getDatabaseProductName = function(callback) { this._dbm.getDatabaseProductName(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the version number of this database product. * * @param {Function} callback * @returns {String} Via callback: database version number */ DatabaseMetaData.prototype.getDatabaseProductVersion = function(callback) { this._dbm.getDatabaseProductVersion(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves this database's default transaction isolation level. * * @param {Function} callback * @returns {Number} Via callback: the default isolation level */ DatabaseMetaData.prototype.getDefaultTransactionIsolation = function(callback) { this._dbm.getDefaultTransactionIsolation(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves this JDBC driver's major version number. * * @param {Function} callback * @returns {Number} Via callback: JDBC driver major version */ DatabaseMetaData.prototype.getDriverMajorVersion = function(callback) { this._dbm.getDriverMajorVersion(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves this JDBC driver's minor version number. * * @param {Function} callback * @returns {Number} Via callback: JDBC driver minor version */ DatabaseMetaData.prototype.getDriverMinorVersion = function(callback) { this._dbm.getDriverMinorVersion(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the name of this JDBC driver. * * @param {Function} callback * @returns {String} Via callback: JDBC driver name */ DatabaseMetaData.prototype.getDriverName = function(callback) { this._dbm.getDriverName(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the version number of this JDBC driver as a String. * * @param {Function} callback * @returns {String} Via callback: JDBC driver version */ DatabaseMetaData.prototype.getDriverVersion = function(callback) { this._dbm.getDriverVersion(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves a description of the foreign key columns that reference the given * table's primary key columns (the foreign keys exported by a table). * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schema - A schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} table - A table name; must match the table name as it is stored in this database * @param {Function} callback * @returns {ResultSet} Via callback: a ResultSet object in which each row is a foreign key column description */ DatabaseMetaData.prototype.getExportedKeys = function(catalog, schema, table, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schema) || _.isUndefined(schema) || _.isString(schema)) && _.isString(table) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getExportedKeys(catalog, schema, table, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves all the "extra" characters that can be used in unquoted identifier * names (those beyond a-z, A-Z, 0-9 and _). * * @param {Function} callback * @returns {String} Via callback: the string containing the extra characters */ DatabaseMetaData.prototype.getExtraNameCharacters = function(callback) { this._dbm.getExtraNameCharacters(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves a description of the given catalog's system or user function * parameters and return type. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} functionNamePattern - A procedure name pattern; must match the function name as it is stored in the database * @param {String} columnNamePattern - A column name pattern; must match the column name as it is stored in the database * @param {Function} callback * @returns {ResultSet} Via callback: each row describes a user function parameter, column or return type */ DatabaseMetaData.prototype.getFunctionColumns = function(catalog, schemaPattern, functionNamePattern, columnNamePattern, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) && (_.isNull(functionNamePattern) || _.isUndefined(functionNamePattern) || _.isString(functionNamePattern)) && (_.isNull(columnNamePattern) || _.isUndefined(columnNamePattern) || _.isString(columnNamePattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getFunctionColumns(catalog, schemaPattern, functionNamePattern, columnNamePattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves a description of the system and user functions available in the * given catalog. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} functionNamePattern - A procedure name pattern; must match the function name as it is stored in the database * @param {Function} callback * @returns {ResultSet} Via callback: each row is a function description */ DatabaseMetaData.prototype.getFunctions = function(catalog, schemaPattern, functionNamePattern, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) && (_.isNull(functionNamePattern) || _.isUndefined(functionNamePattern) || _.isString(functionNamePattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getFunctions(catalog, schemaPattern, functionNamePattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves the string used to quote SQL identifiers. * * @param {Function} callback * @returns {String} Via callback: the quoting string or a space if quoting is not supported */ DatabaseMetaData.prototype.getIdentifierQuoteString = function(callback) { this._dbm.getIdentifierQuoteString(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves a description of the primary key columns that are referenced by * the given table's foreign key columns (the primary keys imported by a * table). * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schema - A schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} table - A table name; must match the table name as it is stored in this database * @param {Function} callback * @returns {ResultSet} Via callback: each row is a primary key column description */ DatabaseMetaData.prototype.getImportedKeys = function(catalog, schema, table, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schema) || _.isUndefined(schema) || _.isString(schema)) && _.isString(table) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getImportedKeys(catalog, schema, table, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves a description of the given table's indices and statistics. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schema - A schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} table - A table name; must match the table name as it is stored in this database * @param {Boolean} unique - When true, return only indices for unique values; when false, return indices regardless of whether unique or not * @param {Boolean} approximate - When true, result is allowed to reflect approximate or out of data values; when false, results are requested to be accurate * @param {Function} callback * @returns {ResultSet} Via callback: each row is an index column description */ DatabaseMetaData.prototype.getIndexInfo = function(catalog, schema, table, unique, approximate, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schema) || _.isUndefined(schema) || _.isString(schema)) && _.isString(table) && _.isBoolean(unique) && _.isBoolean(approximate) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getIndexInfo(catalog, schema, table, unique, approximate, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves the major JDBC version number for this driver. * * @param {Function} callback * @returns {Number} Via callback: JDBC version major number */ DatabaseMetaData.prototype.getJDBCMajorVersion = function(callback) { this._dbm.getJDBCMajorVersion(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the minor JDBC version number for this driver. * * @param {Function} callback * @returns {Number} Via callback: JDBC version minor number */ DatabaseMetaData.prototype.getJDBCMinorVersion = function(callback) { this._dbm.getJDBCMinorVersion(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of hex characters this database allows in an * inline binary literal. * * @param {Function} callback * @returns {Number} Via callback: the maximum length (in hex characters) for a binary literal; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxBinaryLiteralLength = function(callback) { this._dbm.getMaxBinaryLiteralLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters that this database allows in a * catalog name. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed in a catalog name; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxCatalogNameLength = function(callback) { this._dbm.getMaxCatalogNameLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters this database allows for a * character literal. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed for a character literal; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxCharLiteralLength = function(callback) { this._dbm.getMaxCharLiteralLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters this database allows for a column * name. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed for a column name; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxColumnNameLength = function(callback) { this._dbm.getMaxColumnNameLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of columns this database allows in a GROUP BY * clause. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of columns allowed; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxColumnsInGroupBy = function(callback) { this._dbm.getMaxColumnsInGroupBy(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of columns this database allows in an index. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of columns allowed; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxColumnsInIndex = function(callback) { this._dbm.getMaxColumnsInIndex(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of columns this database allows in an ORDER BY * clause. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of columns allowed; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxColumnsInOrderBy = function(callback) { this._dbm.getMaxColumnsInOrderBy(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of columns this database allows in a SELECT * list. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of columns allowed; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxColumnsInSelect = function(callback) { this._dbm.getMaxColumnsInSelect(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of columns this database allows in a table. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of columns allowed; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxColumnsInTable = function(callback) { this._dbm.getMaxColumnsInTable(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of concurrent connections to this database that * are possible. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of active connections possible at one time; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxConnections = function(callback) { this._dbm.getMaxConnections(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters that this database allows in a * cursor name. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed in a cursor name; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxCursorNameLength = function(callback) { this._dbm.getMaxCursorNameLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of bytes this database allows for an index, * including all of the parts of the index. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of bytes allowed; this limit includes the composite of all the constituent parts of the index; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxIndexLength = function(callback) { this._dbm.getMaxIndexLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters that this database allows in a * procedure name. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed in a procedure name; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxProcedureNameLength = function(callback) { this._dbm.getMaxProcedureNameLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of bytes this database allows in a single row. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of bytes allowed for a row; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxRowSize = function(callback) { this._dbm.getMaxRowSize(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters that this database allows in a * schema name. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed in a schema name; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxSchemaNameLength = function(callback) { this._dbm.getMaxSchemaNameLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters this database allows in an SQL * statement. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed for an SQL statement; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxStatementLength = function(callback) { this._dbm.getMaxStatementLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of active statements to this database that can * be open at the same time. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of statements that can be open at one time; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxStatements = function(callback) { this._dbm.getMaxStatements(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters this database allows in a table * name. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed for a table name; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxTableNameLength = function(callback) { this._dbm.getMaxTableNameLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of tables this database allows in a SELECT * statement. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of tables allowed in a SELECT statement; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxTablesInSelect = function(callback) { this._dbm.getMaxTablesInSelect(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves the maximum number of characters this database allows in a user * name. * * @param {Function} callback * @returns {Number} Via callback: the maximum number of characters allowed for a user name; a result of zero means that there is no limit or the limit is not known */ DatabaseMetaData.prototype.getMaxUserNameLength = function(callback) { this._dbm.getMaxUserNameLength(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves a comma-separated list of math functions available with this * database. * * @param {Function} callback * @returns {String} Via callback: the list of math functions supported by this database */ DatabaseMetaData.prototype.getNumericFunctions = function(callback) { this._dbm.getNumericFunctions(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves a description of the given table's primary key columns. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schema - A schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} table - A table name; must match the table name as it is stored in this database * @param {Function} callback * @returns {ResultSet} Via callback: each row is a primary key column description */ DatabaseMetaData.prototype.getPrimaryKeys = function(catalog, schema, table, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schema) || _.isUndefined(schema) || _.isString(schema)) && _.isString(table) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getPrimaryKeys(catalog, schema, table, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves a description of the given catalog's stored procedure parameter * and result columns. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} procedureNamePattern - A procedure name pattern; must match the procedure name as it is stored in the database * @param {String} columnNamePattern - A column name pattern; must match the column name as it is stored in the database * @param {Function} callback * @returns {ResultSet} Via callback: each row describes a stored procedure parameter or column */ DatabaseMetaData.prototype.getProcedureColumns = function(catalog, schemaPattern, procedureNamePattern, columnNamePattern, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) && (_.isNull(procedureNamePattern) || _.isUndefined(procedureNamePattern) || _.isString(procedureNamePattern)) && (_.isNull(columnNamePattern) || _.isUndefined(columnNamePattern) || _.isString(columnNamePattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getProcedureColumns(catalog, schemaPattern, procedureNamePattern, columnNamePattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves a description of the stored procedures available in the given * catalog. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} procedureNamePattern - A procedure name pattern; must match the procedure name as it is stored in the database * @param {Function} callback * @returns {ResultSet} Via callback: each row is a procedure description */ DatabaseMetaData.prototype.getProcedures = function(catalog, schemaPattern, procedureNamePattern, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) && (_.isNull(procedureNamePattern) || _.isUndefined(procedureNamePattern) || _.isString(procedureNamePattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getProcedures(catalog, schemaPattern, procedureNamePattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves the database vendor's preferred term for "procedure". * * @param {Function} callback * @returns {String} Via callback: the vendor term for "procedure" */ DatabaseMetaData.prototype.getProcedureTerm = function(callback) { this._dbm.getProcedureTerm(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Retrieves a description of the pseudo or hidden columns available in a given * table within the specified catalog and schema. * * @param {String} catalog - A catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search * @param {String} schemaPattern - A schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search * @param {String} tableNamePattern - A table name pattern; must match the table name as it is stored in the database * @param {String} columnNamePattern - A column name pattern; must match the column name as it is stored in the database * @param {Function} callback * @returns {ResultSet} Via callback: each row is a column description */ DatabaseMetaData.prototype.getPseudoColumns = function(catalog, schemaPattern, tableNamePattern, columnNamePattern, callback) { var validParams = ( (_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) && (_.isNull(schemaPattern) || _.isUndefined(schemaPattern) || _.isString(schemaPattern)) && (_.isNull(tableNamePattern) || _.isUndefined(tableNamePattern) || _.isString(tableNamePattern)) && (_.isNull(columnNamePattern) || _.isUndefined(columnNamePattern) || _.isString(columnNamePattern)) ); if(! validParams) { return callback(new Error('INVALID ARGUMENTS')); } this._dbm.getPseudoColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern, function(err, result) { if (err) { return callback(err); } return callback(null, new ResultSet(result)); }); }; /** * Retrieves this database's default holdability for ResultSet objects. * * @param {Function} callback * @returns {Number} Via callback: the default holdability; either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT */ DatabaseMetaData.prototype.getResultSetHoldability = function(callback) { this._dbm.getResultSetHoldability(function(err, result) { if (err) { return callback(err); } return callback(null, result); }); }; /** * Indicates whether or not this data source supports the SQL ROWID type, and * if so the lifetime for which a RowId object remains valid. * * NOTE: This method should be used with caution for now. The RowIdLifetime object * returned is a Java object and is not wrapped by the node-jdbc library. * * @param {Function} callback * @returns {RowIdLifetime} Via callback: the status indicating the lifetime of a RowId */ DatabaseMetaData.prototype.getRowIdLifetime = function(callback)