Data source name
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. The term often overlaps with "connection string". Most systems do not make a distinction between DSNs or connection strings and the term can often be used interchangeably. 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. Standardizing DSNs offers a level of indirection; various applications (for example: Apache/PHP and IIS/ASP) can take advantage of this in accessing shared data sources.
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. The term often overlaps with "connection string". Most systems do not make a distinction between DSNs or connection strings and the term can often be used interchangeably. 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. Standardizing DSNs offers a level of indirection; various applications (for example: Apache/PHP and IIS/ASP) can take advantage of this in accessing shared data sources. Dim DatabaseObject1 Set DatabaseObject1 = Server.CreateObject("ADODB.Connection") DatabaseObject1.Open("DSN=example;") 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 = " :// : @ : / "; $dsn = "mysql://john:pass@localhost:3306/my_db"; $db = DB::connect($dsn); PHP with PDO: $dsn = "mysql:host=localhost;dbname=example"; $dbh = new PDO($dsn, $username, $password); In Perl, using the Perl DBI module, each driver has its own syntax for the DSN attributes. The only requirement that DBI makes is that all the information, except for username and password is supplied in a single string argument. my $dsn = "DBI:Pg:database=finance;host=db.example.com;port=$port"; $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; $dsn = "DBI:Oracle:host=$host;sid=$sid;port=$port"; $dsn = "DBI:SQLite:dbname=$dbfilename"; my $dbh = DBI->connect($dsn,'username','password');
References
No reference rows published for this article.
Cite this article
MLA
"Data source name." encyclopegia.org, 2026, https://encyclopegia.org/wiki/data-source-name. Accessed 24 November 2026.
Chicago
"Data source name." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/data-source-name.
APA
encyclopegia.org. (2026). Data source name. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/data-source-name
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON