Data source name
|This article does not cite any references or sources. (January 2009)|
In computing, a data source name (DSN, sometimes known as a database source name, though "data sources" can comprise other repositories apart from databases) is a string that has an associated data structure used to describe a connection to a data source. Most commonly used in connection with ODBC, DSNs also exist for JDBC and for other data access mechanisms.
DSN attributes may include, but are not limited to:
- the name of the data source
- the location of the data source
- the name of a database driver which can access the data source
- a user ID for data access (if required)
- a user password for data access (if required)
The system administrator of a client machine generally creates a separate DSN for each relevant data source.
Types of data source name
Two kinds of DSN exist:
- Machine DSNs - stored in collective configuration files (e.g., /etc/odbc.ini, ~/.odbc.ini) and/or system resources (e.g., Windows Registry HKLM\Software\ODBC\odbc.ini)
- File DSNs - stored in the filesystem with one DSN per file
These are further broken down into
- System DSNs - accessible by any and all processes and users of the system, stored in a centralized location (e.g., /etc/odbc.ini, /etc/odbc_file_dsns/<filename>)
- User DSNs - accessible only by the user who created the DSN, stored in a user-specific location (e.g., ~/.odbc.ini, ~/odbc_file_dsns/<filename>)
Misuse of the term
The term DSN is sometimes mistakenly used in place of connection string. A connection string typically fully describes a data source, while a DSN typically relies on some external system resources and/or configuration file.
Example of use
Software (e.g., Crystal Reports, Microsoft Excel, PHP, Perl, Python, Ruby) users can submit CRUD (Create, Read, Update, Delete) queries to a data source by establishing a connection to the DSN.
might look like the following:
Dim DatabaseObject1 Set DatabaseObject1 = Server.CreateObject("ADODB.Connection") DatabaseObject1.Open("DSN=DSNname;")
In PHP using the PEAR::DB package to open a connection without an external DSN (a "DSN-less connection", i.e., using a Connection String), the code might resemble the following
require_once("DB.php"); //$dsn = "<driver>://<username>:<password>@<host>:<port>/<database>"; $dsn = "mysql://john:pass@localhost:3306/my_db"; $db = DB::connect($dsn);
|This database-related article is a stub. You can help Wikipedia by expanding it.|