The driver uses a DSN mechanism that allows certain attributes to be set at connection time.
The DSN attribute syntax is the same as the Open Source DBD::Sybase driver. Therefore, you need not change Perl scripts or maintain different versions for DBD::Sybase versus DBD::SybaseASE. However, DBD::SybaseASE does not support some attributes that are considered obsolete. See “Currently unsupported DSN syntax”.
DBI->connect("dbi:SybaseASE:attr=value;attr=value", $user_id, $password, %attrib);
The dbi:SybaseASE: section obtains the package name of the driver so it can be loaded. When the DSN is passed into the driver, the system removes this part and the remaining string holds the key and value pairs to be dissected.
The $user_id and $password credentials
are separate API arguments; they are not part of the DSN string.
The %attrib argument is an optional, comma-separated chain of key-value pairs that set options at connection time. They are passed into the driver and handled during a connect() call. For example:
DBI->connect("dbi:SybaseASE:server=mumbles; user, password, PrintError => 1, AutoCommit = 0);
These attributes are currently supported when connecting to a server:
server – specifies the server to which you are connecting. The driver currently assumes this option is set. If server is not specified, use the ENV{"DSQUERY"} mechanism to obtain a server name.
database – specifies which database within the server is the target database at connect time. If no database is specified, the master database is used.
hostname – specifies, in the value section, the host name that is stored in the sysprocesses table for this process. If no hostname is specified, the host on which the Perl application executes is used.
language – specifies the locale to be used on this connection. If no language is specified, the internal default locale named CS_LC_ALL is used.
charset – specifies the charset to be used on this connection. If no charset is specified, the internal default that is, utf8, is used.
host; port – specifies the combination of host and port to use instead of relying on the interfaces file entries.
In the Perl DSN syntax, host and port are separate options.
An alternative DSN form similar to the following is not currently
supported:
host:port=mumbles:1234
When the host and port DSN options are provided with the intent of not using the interface file, the host and port must suffice to connect. If the DSN attribute “server=” is also provided with the host and port combination, the connection fails.
Therefore, the usage of either host and port must be used to establish a connection or server alone must be used. The two DSN attributes (server versus host/port) are mutually exclusive.
timeout – specifies the connection timeout value. Set to 0 or a negative value for no timeout.
loginTimeout – specifies the login timeout value, in seconds. The default value is 60 seconds. Set loginTimeout=value in seconds to enable this attribute.
tds_keepalive – specifies the KEEP_ALIVE attribute on the connection. Set tds_keepalive=1 to enable this attribute.
packetSize – specifies the TDS packet size for the connection. By default, the lower bound, which is set in the driver, is 2048. The maximum value is determined by the server, and is not set in the driver.
maxConnect – increases or decreases the number of connections allowed. The range of values is 1 – 128; the default is 25.
encryptPassword – specifies whether to use password encryption. Set encryptPassword=1 to enable this attribute.
sslCAFile – specifies an alternate location for the trusted.txt file. Specify an absolute path of up to 256 characters.
scriptName – specifies the chosen name of the top-level Perl script that drives the application. This name appears in the sysprocesses table as the application name. Absence of this value gives a default application name that is obtained from the Perl internal environment. This value can be as many as 256 characters.
The application name fed into the SybaseASE Driver is
either set through the DSN scriptName option
or is derived from the Perl internal environment.
interfaces – specifies an alternate location to the Sybase interfaces file. Same constraints apply to the sslCAFile and scriptName options.
You can repeat attribute values as long as they are recognized by the driver. Illegal attributes cause the DBI->connect() call to fail.
The attribute names follow the Open Source Sybase Perl
driver.
DSN-specific example:
$dbh = DBI->connect("dbi:SybaseASE:server=mumbles", $user, $passwd);
Alternatively, use the DSQUERY environment variable:
my $srv = $ENV{"DSQUERY"};$dbh = DBI->connect("dbi:SybaseASE:server=$srv", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:host=tzedek.sybase.com;port=8100", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:maxConnect=100", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:database=sybsystemprocs", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:charset=iso_1", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:language=us_english", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:packetSize=8192", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:interfaces=/opt/sybase/interfaces", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:loginTimeout=240", $user, $passwd);
$dbh = DBI->connect("dbi:SybaseASE:timeout=240", $user, $passwd);
$dbh = DBI->connect("dbi:Sybase:scriptName=myScript", $user, $password);
$dbh = DBI->connect("dbi:SybaseASE:hostname=pedigree", $user, $password);
$dbh = DBI->connect("dbi:SybaseASE:encryptPassword=1", $user, $password);
$dbh = DBI>connect("dbi:SybaseASE:sslCAFile=/usr/local/sybase/trusted.txt", $user, $password, AutoCommit => 1);
DSN-specific example combination:
$dbh = DBI->connect("dbi:SybaseASE:server=mumbles, database=tempdb;packetSize=8192;
language=us_english;charset=iso_1;encryptPassword=1", $user, $pwd, AutoCommit=>1, PrintError => 0);
tdsLevel
kerberos; for example:
$dbh = DBI->connect("dbi:SybaseASE:kerberos=$serverprincipal", '', '');
bulkLogin; for example:
$dbh = DBI->connect("dbi:SybaseASE:bulkLogin=1", $user, $password);
serverType