Creates, deletes, describes, and lists SQL Anywhere ODBC data sources.
dbdsn [ modifier-options ] { -l[ s | u ] | -d[ s | u ] dsn | -g[ s | u ] dsn | -w[ s | u ] dsn [details-options;...] | -cl }
Major option | Description |
---|---|
@data |
Reads in options from the specified environment variable or configuration file. See Configuration files. If you want to protect passwords or other information in the configuration file, you can use the File Hiding utility to obfuscate the contents of the configuration file. See File Hiding utility (dbfhide). |
-l[ s | u ] | Lists the available SQL Anywhere ODBC data sources. You can modify the list format using the -b or -v options. On Windows, you can modify the option using the u (user) or s (system) specifiers. The default specifier is u. |
-d[ s | u ] dsn | Deletes the named SQL Anywhere data source. If you supply -y, any existing data source is deleted without confirmation. On Windows, you can modify the option using the u (user) or s (system) specifiers. The default specifier is u. |
-g[ s | u ] dsn | Lists the definition of the named SQL Anywhere data source. You can modify the format of the output using the -b or -v options. On Windows, you can modify the option using the u (user) or s (system) specifiers. The default specifier is u. |
-w[ s | u ] dsn [ details-options ] | Creates a new data source, or overwrites one if one of the same name exists. You must specify the -c option with the -w option. If you supply -y, any existing data source is overwritten without confirmation. On Windows, you can modify the option using the u (user) or s (system) specifiers. The default specifier is u. |
-cl |
Lists the connection parameters supported by the dbdsn utility. See Connection parameters. For information about supported ODBC connection parameters, see ODBC connection parameters. |
Modifier-options | Description | ||
---|---|---|---|
-b | Formats the output of the list as a single line connection string. | ||
-cm |
Displays the command used to create the data source. This option can be used to output the creation command to a file, which can be used to add the data source to another computer or can be used to restore a data source to its original state if changes have been made to it. You must specify the -g option or -l option with -cm or the command fails. Specifying -g displays the creation command for the specified data source, while specifying -l displays the creation command for all data sources. If the specified data source does not exist, the command to delete the data source is generated. For example, if the mydsn
data source does not exist on the computer,
|
||
-dr |
Includes the Driver parameter when displaying data sources. When you use the -cm option to recreate data sources, it allows the current version of dbdsn to create data sources that reference a different version of the ODBC driver. For example, run the following command to create a version 11 data source:
When you run However, if you run |
||
-f | Displays the name of the system file that is being used. This option is only available on Unix. | ||
-ns |
Specifies that the environment variable settings are used to determine the location of the system information file (named .odbc.ini by default). This option is also useful for determining which file is being used by dbdsn when there are multiple candidates for the system information file in the environment. This option is only available on Unix. If you do not specify -ns when creating a data source, dbdsn also checks for the system information file in the user's home directory and the path. For more information about how the system information file is located, see ODBC data sources on Unix. |
||
-o filename | Writes output messages to the named file. | ||
-or |
Creates a data source for the iAnywhere Solutions Oracle driver when specified with the -c option. For example:
You can specify the -cl option with the -or option to obtain a list of the connection parameters for the iAnywhere Solutions Oracle driver. |
||
-pe | Encrypts the password specified in the Password connection parameter, and stores the encrypted password in the data source using the ENP connection parameter. | ||
-q | Suppresses output to the database server messages window. If you specify -q when deleting or modifying a data source, you must also specify -y. | ||
-v | Formats the output of the list over several lines, as a table. | ||
-y | Deletes or overwrites each data source without prompting you for confirmation. If you specify -q when deleting or modifying a data source, you must also specify -y. |
Details-options | Description |
---|---|
-c "keyword=value;..." | Specifies connection parameters as a connection string. See Connection parameters. |
-cw | Ensures that the DBF parameter (specified using -c) is an absolute file name. If the value of DBF is not an absolute file name, dbdsn will prepend the current working directory (CWD). This option is useful because some operating systems do not have CWD information readily available in batch files. |
The modifier options can occur before or after the major option specification.
The Data Source utility is a cross-platform alternative to the ODBC Data Source Administrator for creating, deleting, describing, and listing SQL Anywhere ODBC data sources. The utility is useful for batch operations.
Storing user IDs, passwords (encrypted or unencrypted), and/or database keys in a data source is not secure. It is recommended that you do not store this information in a data source if the database contains sensitive data.
On Windows operating systems, the data sources are held in the registry.
For information about creating a data source on Windows using the ODBC Data Source Administrator, see ODBC data sources.
On Unix operating systems, data sources are held in the system information file (named .odbc.ini by default). When you use the Data Source utility to create or delete SQL Anywhere ODBC data sources on Unix, the utility
automatically updates the [ODBC Data Sources]
section of the system information file. If you do not specify the Driver connection parameter using the -c option on Unix,
the Data Source utility automatically adds a Driver entry with the full path of the SQL Anywhere ODBC driver based on the
setting of the SQLANY12 environment variable.
For more information about the system information file, see ODBC data sources on Unix.
For information about supported ODBC connection parameters, see ODBC connection parameters.
You should not obfuscate the system information file (.odbc.ini) with the File Hiding utility (dbfhide) on Unix unless you will only be using SQL Anywhere data sources. If you plan to use other data sources (for example, for MobiLink synchronization), then obfuscating the system information file may prevent other drivers from functioning properly.
Exit codes are 0 (success) or non-zero (failure). See Software component exit codes.
Write a definition of the data source newdsn. Do not prompt for confirmation if the data source already exists.
dbdsn -y -w newdsn -c "UID=DBA;PWD=sql;Host=myhost" |
or, with a different option order,
dbdsn -w newdsn -c "UID=DBA;PWD=sql;Host=myhost" -y |
List all known user data sources, one data source name per line:
dbdsn -l |
List all known system data sources, one data source name per line:
dbdsn -ls |
List all data sources along with their associated connection string:
dbdsn -l -b |
Report the connection string for the user data source MyDSN:
dbdsn -g MyDSN |
Report the connection string for the system data source MyDSN:
dbdsn -gs MyDSN |
Delete the data source BadDSN, but first list the connection parameters for BadDSN and prompt for confirmation:
dbdsn -d BadDSN -v |
Delete the data source BadDSN without prompting for confirmation.
dbdsn -d BadDSN -y |
Create a data source named NewDSN for the database server MyServer:
dbdsn -w NewDSN -c "UID=DBA;PWD=sql;Server=MyServer" |
If NewDSN already exists, you are prompted to confirm overwriting the data source.
List all connection parameter names and their aliases:
dbdsn -cl |
List all user data sources:
dbdsn -l -o dsninfo.txt |
List all connection parameter names:
dbdsn -cl -o dsninfo.txt |
Specify an absolute file name. When the ODBC data source is created, it contains DBF=c:\SQLAnywhere12\my.db.
c:\SQLAnywhere12> dbdsn -w testdsn -cw -c UID=DBA;PWD=sql;Server=SQLAny;DBF=my.db |
Run the following command to create the SQL Anywhere 12 Demo data source and output it to a file called restoredsn.bat:
dbdsn -cm -gs "SQL Anywhere 12 Demo" > restoredsn.bat |
The restoredsn.bat file contains the following:
dbdsn -y -ws "SQL Anywhere 12 Demo" -c "UID=DBA;PWD=sql; DBF='C:\Documents and Settings\All Users\Documents\SQL Anywhere 12\Samples\demo.db'; Server=demo12;START='C:\Program Files\SQL Anywhere 12\Bin32\dbeng12.exe'; ASTOP=yes;Description='SQL Anywhere 12 Sample Database'" |
Run the following command to return the location of the system information file on Unix:
dbdsn -f |
This command returns the following output:
dbdsn using /home/user/.odbc.ini |
Change the location of the system information file:
export ODBCINI=./myodbc.ini |
Verify the new location of the system information file using dbdsn -f
:
dbdsn using ./myodbc.ini |
Use the -ns option when creating the data source:
dbdsn -w NewDSN -c "UID=DBA" -ns |
This results in the following output:
Configuration "newdsn" written to file ./myodbc.ini |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |