14
Interacting with Databases
Establishing an ADBC Connection
The
connection
object’s
getTableList
method returns an array of
TableInfo
generic objects, each of which corresponds to a table within the database and contains the
following properties:
●
●
name
: the table name
description
: a description of database-dependent information about the table
In the following example, the name and description of every table in the database is
printed to the console:
// Obtain the array of TableInfo objects representing the database tables:
var tableArray = myConnection.getTableList();
// Print the name and description of each table to the console:
for (var i=0; i<tableArray.length; i++) {
console.println("Table Name: " + tableArray[i].name);
console.println("Table Description: " + tableArray[i].description);
}
The
connection
object’s
getColumnList
method accepts a parameter containing the
name of one of the database tables, and returns an array of
ColumnInfo
generic objects,
each of which corresponds to a column within the table and contains the following
properties:
name
: the name of the column
●
description
: a description of database-dependent information about the column
●
type
: a numeric identifier representing an
ADBC
SQL type
●
typeName
: a database-dependent string representing the data type
In the following example, a complete description of every column in the
Q32000Data
database table called
Sales
is printed to the console:
●
// Obtain the array of ColumnInfo objects representing the Sales table:
var columnArray = myConnection.getColumnList("Sales");
// Print a complete description of each column to the console:
for (var i=0; i<columnArray.length; i++) {
console.println("Column Name: " + columnArray[i].name);
console.println("Column Description: " + columnArray[i].description);
console.println("Column SQL Type: " + columnArray[i].type);
console.println("Column Type Name: " + columnArray[i].typeName);
}
240
Acrobat JavaScript Scripting Guide