Product Home Page | Developer Site | Version | |
When you want to connect to a database from an ASP page, the first step is to create the connection string. This provides information (in the form of parameters and their values) that is required for the server to establish the connection.
Each type of database has a specific set of parameters for which you must specify values; these are the required parameters. Some databases also provide optional parameters that you can specify to implement special features.
Exactly what you must include in a connection string depends on the type of database and the approach you use to specify its parameters. Sun ONE Active Server Pages supports the following three approaches to specifying parameters in a connection string:
System DSN: With a system DSN, all you need to provide in the connection string is the name of the DSN that your system administrator has configured for the database on the ASP Server.
File DSNs: A file DSN is similar to a system DSN, except the database information is contained in a file (*.dsn) that can be stored in the root directory for a virtual host, rather than being stored centrally by the ASP Server. File DSNs are useful in shared Web hosting environments because a system administrator does not need to configure each file DSN; users can configure their own.
DSN-less connection strings: With a DSN-less connection string, you specify all of the required database information in the connection string.
Note | Connection strings must be constructed according to the requirements of the ODBC driver being used. Sun ONE ASP for Windows uses standard Windows ODBC drivers, so connection strings you developed for Windows will work. However, the ODBC drivers for UNIX and Linux platforms are different than for Windows, so before you can use Windows connection strings with Sun ONE Active Server Pages for UNIX or Linux, you may need to use the syntax described in this section. |
When creating file system references in ASP applications, keep in mind that UNIX and Linux are case-sensitive operating systems. Be sure to use the correct capitalization in all references to files and directories. |
Ask your server administrator which approach you should use in your specific Web server environment.
Once you have created the connection string in your ASP page, you can add the code needed to open a database connection, as described in Opening the Database Connection.
Note | On UNIX and Linux systems, Sun ONE ASP installs the ODBC drivers to support a number of databases. However, it does not support all databases on all platforms. To see the list of installed drivers for your platform, see Supported in This Release. |
In this section:
Using DSN-less Connection Strings
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.