Data source name

from Wikipedia, the free encyclopedia

The Data Source Name (DSN) is a data structure (for example a URI, or a file path) which describes the access data that a driver needs to use in database abstraction frameworks ( database abstraction layer ) such as ODBC (Open Database Connectivity), JDBC or ADOdb connect to a specific database based on a specific RDBMS .

The DSN contains information such as the name, directory, and driver of the database and, based on the type of DSN, the user's ID and password.

Depending on the framework, the notation of the DSN differs significantly:

Different notations

JDBC

jdbc:sybase://127.0.0.1:700/MyDataBase

PEAR :: db (PHP Framework)

mysql://root:rootpw@localhost/MyDataBase

ODBC

There are various forms of representation for ODBC DSNs. Either the DSNs are 'hard-wired' and built into the program code as a DSN-less connection. Then the representation is as follows:

  DBQ=C:\TEST\QUERY FILES;DefaultDir=C:\TEST\QUERY FILES; _
  Deleted=1;Driver={Microsoft dBase Driver (*.dbf)}; _
  DriverId=277;FIL=dBase IV;PageTimeout=600;Statistics=0

In addition, it is possible to save the DSN in the registry (in older versions of MS-Query) or in so-called File DSNs. This designation is somewhat unfortunate by Microsoft, since it is not a DSN reference TO a file (e.g. XML file), but a DSN reference IN a file.

Accordingly, a file DSN or a DSN file can contain the data in a notation similar to that in an .ini file:

  [ODBC]
  DRIVER=Microsoft Excel Driver (*.xls)
  UID=admin
  UserCommitSync=Yes
  Threads=3
  SafeTransactions=0
  ReadOnly=1
  PageTimeout=5
  MaxScanRows=8
  MaxBufferSize=512
  ImplicitCommitSync=Yes
  FIL=excel 5.0
  DriverId=790
  DefaultDir=<drive letter>:\ 
  DBQ=<drive letter>:\<source filename>

ODBC distinguishes between three types of DSN:

  • User DSN
  • System DSN (Machine DSN)
  • File DSN

User and system DSNs are machine specific and store the DSN information in the registry. A user DSN allows database access for a single user on a single computer, a system DSN for each user of a specific computer. A file DSN contains relevant information in a text file with a .DSN file extension and can be used by multiple users and multiple computers if they have installed the same database driver.

Web links