PSConnectionParmsClass

Specifies the database connection parameters required for a Web DataWindow control to connect to a database. The object does not connect to the database.

Unless you use the two-argument syntax for JSP targets, you need to be familiar with the connection parameters for your database system before using this object. The PowerBuilder book Connecting to Your Database provides information about making database connections.

For ASP targets, if you want to set up a database connection to a database that has a named connection, use the PSNamedConnectionParmsClass object.

Syntax

Syntax with single argument

PSConnectionParmsClass(connectString)

Syntax with two arguments (JSP targets only)

PSConnectionParmsClass(DBProfile, Prop)

Syntax with multiple arguments

PSConnectionParmsClass(connectString, username, password, dbms, lock, database, serverName)

Constructors

PSConnectionParmsClass constructor

Datatype

Description

connectString

String

The connection parameters required to connect to the database. This string is specific to the database driver for your database DBMS. It must not include spaces that are not part of the string value.

DBProfile

String

The connection parameters defined in the database.properties file in the \WEB-INF\classes directory. This file is created when you build the JSP target and its content is taken from the database profiles defined in PowerBuilder.

Prop

Boolean

This value is always “true”. It is used to distinguish the constructor syntax with the DBProfile argument from the syntax with the connectString argument.

username

String

The user name that the object uses to connect to the specified database.

password

String

The password that the object uses to connect to the specified database.

dbms

String

The connection mechanism used to connect to the database. An entry for dbms is optional for ASP targets. The default is ODBC.

lock

String

The lock value required by your database to prevent concurrent transactions for interfering with each other and compromising the data in the database. An entry for lock is optional for ASP targets.

database

String

The name of the database. An entry for database is optional for ASP targets.

serverName

String

The name of the server that runs the database. An entry for serverName is optional for ASP targets.

Examples

Example 1

The following example for an ASP target creates a new object named "connParm". The new object defines a connection to the database using the connect string "mydb" and the user name and password "guest". The connection is made through ODBC.

Var connParm = new PSConnectionParmsClass(mydb, guest,
		guest, ODBC)

NoteOptional arguments in constructor for ASP targets Although the last three arguments in the constructor for ASP targets are optional, if you enter a value for the database or serverName arguments, the optional arguments that can precede the value you enter are no longer optional and must be included in the constructor.

Example 2

For JSP targets, you must assign a variable as an object of PSConnectionParmsClass type before you can instantiate it, and you must use semicolons to terminate each line of code:

PSConnectionParmsClass  dbConn = new PSConnectionParmsClass("ConnectString='DSN=EAS Demo DB V4;UID=dba;PWD=sql',ConnectOption='SQL_DRIVER_CONNECT,SQL_DRIVER_NOPROMPT'" );