Database Connectivity via Server Side JavaScript
The server side JavaScript running on the Enterprise Server
gives you many options for the access of several of the
major database's in use today. A few of the more widely
known databases which may be accessed are the Informix,
Oracle, Sybase, all of the many SQL flavors, DB2, and any
ODBC compliant database. The actual accessing and
manipulation of your databases is accomplished through the
use of the LiveWire service provided with the Enterprise
Server. Basically, it is a set of generic JavaScript scripts
that enable you to work with your databases.
The various connections to your database are kept within
what is called a "pool" of database connections. An entry is
added to the pool through the creation of a new DbPool
object within your server side script. Once created, you may
access any of the databases within the pool. There are many
properties available to establish your connection in the
manner you require. The following is a list of the options
available.
- DBType - This is used to specify the type of database
(the "flavor"). Available options for this property are
ORACLE, SYBASE, INFORMIX, DB2 and ODBC. Note the
capitalization of the database names.
- DBInstance - This is used to specify the instance name
of the database, which is the DSN entry name for ODBC
compliant databases.
- UID - This is used to specify the User ID you wish to
use to connect to the database.
- PWD - This is used to specify the password that will be
used in conjunction with the User ID to establish the
connection to the database. Obviously, it must be the
correct password for the User ID you are using.
- DBName - This is used to provide the name of the
database you are going to access and possibly manipulate via
the web page. It should be noted that for Oracle, DB2, and
ODBC compliant database connections, this should be left as
a set of blank quotes ( " " ).
- MacConn - This is used to specify the maximum allowed
number of connections to the database allowed at one
time.
- CommitFlag - This is used to specify whether or not a
pending transaction to the database will be allowed directly
after the current session is closed. If it is set to false,
the new transaction is not allowed. If it set to true, the
new transaction is allowed.
It is important to note that the properties given can be
used in combinations with each other, within the same set of
commands. You may also state no properties, but not during
the initial contact with the database. When first contacting
the database, you must use at least one and possibly all of
the properties of the DBPool object to obtain a successful
connection. Once the pool is created, you may use any
databases you have a need for.
Join us next week where we delve deeper into JavaScript and
examine how to send mail on the server side using
JavaScript...
Introduction to Server Side JavaScript
The JavaScript Chronicles
Server Side JavaScript Mail Sending
The JavaScript Chronicles
JavaScript Introduction
Part 2: Data Types
Part 3: Arrays
Part 4: Operators
Part 5: Conditional Statements
Part 6: JavaScript Functions
Part 7: Pattern Matching - The RegExp Object
Part 8: Introduction to Server Side JavaScript
Part 9: Server Side JavaScript Mail Sending
Part 10: Server Side JavaScript and File Manipulation
Part 11: Working with Forms in JavaScript
Part 12: Getting to Know Dynamic HTML
|