14
Interacting with Databases
Introduction to ADBC
Introduction to ADBC
Acrobat JavaScript provides an ODBC-compliant object model called Acrobat Database
Connectivity (ADBC), which can be used in document-level scripts to connect to a database
for the purposes of inserting new information, updating existing information, and deleting
database entries. ADBC provides a simplified interface to ODBC, which it uses to establish a
connection to a database and access its data, and supports the usage of SQL statements for
data access, update, deletion, and retrieval.
Thus, a necessary requirement to the usage of ADBC is that ODBC must be installed on a
client machine running a Microsoft Windows operating system. In addition, ADBC does not
provide security measures with respect to database access; it is assumed that the database
administrator will establish and maintain the security of all data.
The Acrobat JavaScript
ADBC
object thus provides methods through which you can obtain
a list of accessible databases and form a connection with one of them. These methods are
called
getDataSourceList
and
newConnection
. In addition, the
ADBC
object
provides a number of properties corresponding to all supported SQL and Acrobat
JavaScript data types, which include representations of numeric, character, time, and date
formats.
Establishing an ADBC Connection
There are normally two steps required to establish an ADBC connection. First, obtain a list
of accessible databases by invoking the
ADBC
object’s
getDataSourceList
method.
Then establish the connection by passing the Data Source Name (DSN) of one of the
databases in the list to the
ADBC
object’s
newConnection
method.
The
getDataSourceList
method returns an array of
DataSourceInfo
generic
objects, each of which contains the following properties:
●
●
name
: a string identifying the database
description
: a description containing specific information about the database
In the following example, a list of all available databases is retrieved, and the DSN of the
DataSourceInfo
object representing
Q32000Data
is identified and stored in variable
DB
:
238
Acrobat JavaScript Scripting Guide