Chapter 3 Working with Dynamo Web Sites


Working with Web sites

You create and work with Web sites using Sybase Central. Because PowerDynamo plugs into Sybase Central you can manage both your databases and your Web sites from within Sybase Central.

What is a Dynamo Web site?

A Dynamo Web site consists of:

Web site architecture

How documents are stored

Dynamo Web sites include:

Web site documents are usually stored in an Adaptive Server Enterprise or Adaptive Server Anywhere relational database in a set of tables. However, the structure of these tables is hidden from the user by the PowerDynamo application server. Web sites may also be hosted in the file system.

The data may be contained in an Adaptive Server Enterprise or Adaptive Server Anywhere database, or in some other ODBC or Open Client data source.

Hierarchical views of documents

Sybase Central provides a hierarchical view of a Web site, just like a directory structure. A hierarchical architecture has advantages for a Web site:

Storing documents on disk

Not all the documents in a site need be held in a database. Web sites can also contain documents stored in folders on disk.

For information about creating dynamic file-based Web sites see "Creating a dynamic file-based Web site "

For more information about storing documents on disk and linking these into a database-hosted Web site, see "Linking folders to directories on disk".

Before you begin

You should be familiar with the basics of using Sybase Central for managing databases. For assistance with using Sybase Central, see the Sybase Central online help for Dynamo.

Creating a Web site [Adaptive Server Anywhere]

You create Dynamo Web sites from Sybase Central, the management tool included in Dynamo, Adaptive Server Anywhere, and Adaptive Server Enterprise.

Web site created at the server

Sybase Central is a client application. You can use Sybase Central to create a database-hosted Web site on a database residing anywhere on the network. There is no requirement for Sybase Central to run on the same machine as the database server.

Steps To create a Web site from Sybase Central [Adaptive Server Anywhere]:

  1. If you do not wish to use an existing database to hold the Web site, create a database to hold the Web site. You can do this using the Create Database utility, which is in the Sybase Adaptive Server Anywhere container in Sybase Central.

    For more information about creating a database, see the Sybase Central online help and "Working with Database Objects" in the Adaptive Server Anywhere User's Guide.

  2. Start Sybase Central.

  3. Create an ODBC data source definition for this database. Use the ODBC Administrator from the Utilities folder in Sybase Central.

    For more information about creating an ODBC data source, see "Connecting to a Database" in the Adaptive Server Anywhere User's Guide.

  4. Create a connection profile for your Web site.

    1. Select Tools | Connect Profiles.
    2. Click New. In the Create New Profile window, enter the name of the profile (this name is used to identify the Web site in Sybase Central) and select PowerDynamo as the type. Click OK.
    3. Fill in the fields in the Connection Profile window. If you are creating an ODBC connection profile, you would:
      • Select the data source you have created from the drop-down list of ODBC data sources,
      • Enter a valid user ID. Adaptive Server Anywhere databases are created with a single user, with DBA authority. The user ID is DBA and the password is SQL.

    4. When you have filled in all fields, click OK.
      For information on creating File connection profiles, see "Creating a connection profile for your Web site".


  5. From the Connection Profile window, highlight the connection profile you just created and click Connect.

  6. If no Web site exists for the user ID you have specified on the database, Dynamo prompts you to add a Web site.



  7. To configure this Web site to be accessible from a Web server, see "Configuring Web sites".


Notes

Creating a Web site [Adaptive Server Enterprise]

You create Dynamo Web sites from Sybase Central, the management tool included with Adaptive Server Enterprise.

Web site created at the server

Sybase Central is a client application. You can use Sybase Central to create a database-hosted Web site on a database residing anywhere on the network. There is no requirement for Sybase Central to run on the same machine as the database server.

Steps To create a Web site from Sybase Central [Adaptive Server Enterprise]:

  1. From Sybase Central, connect to the Adaptive Server where you want to create the Web site, or create a new database.

  2. Now you need to connect to the database as a Web site. To do this, you must connect using a Dynamo connection, not an Adaptive Server Enterprise connection, within Sybase Central.

  3. Create a connection profile for your Web site.

    1. Select Tools | Connect Profiles.
    2. Click New.
    3. In the Create New Profile window, enter the name of the profile and select PowerDynamo as the type. Click OK.
    4. Change the connection type to Open Client.
    5. Fill in the fields in the Connection window:
      • Enter a descriptive name in the Connection Name field, such as My First Site. This name is used to identify the Web site in Sybase Central. You can use spaces in the name if you wish.
      • Enter the names of the server and database to connect to. These names are case sensitive.
      • Enter a valid user ID and password for this database. The user ID must have the permissions necessary to create tables.

    6. When you have filled in all fields, click OK.
      For information on creating ODBC and File connection profiles, see "Creating a connection profile for your Web site".


  4. Highlight the connection profile you just created and click Connect.

  5. If no Web site exists for the user ID you have specified on the database, Dynamo prompts you to add a Web site.



  6. To configure this Web site to be accessible from a Web server, see "Configuring Web sites".


Notes

Creating a dynamic file-based Web site

You can use Sybase Central to create a file-based Web site that resides on any drive that is accessible (locally or via a network) from the machine where Sybase Central is running. File-based sites dynamically connect to a database and retrieve data.

WARNING!

Caution
All files in the target directory will be deleted when creating a dynamic file-based Web site. If there are read-only files in this directory the Web site will not be created.

Steps To create a file-based Web site from Sybase Central:

  1. Create a directory for store your Web site.

  2. From Sybase Central, select Tools | Connect.

  3. In the connection profile window:



    Click OK.

  4. If no Web site exists in the directory, Dynamo prompts you to add a Web site.

  5. Select the appropriate boxes to load the PowerDynamo documentation and samples into the Web site, and click OK to create the site.

  6. To configure this Web site to be accessible from a Web server, see "Configuring Web sites".


Notes

WARNING!

Caution
File-based Web sites store database passwords as plain text which makes them accessible through the file system.

Retrieving data from a database with a dynamic file-based Web site

After you have created a dynamic file-based Web site, you must create a connection to the database and specify the connection name in the root folder of the file-based Web site.

Steps To retrieve data from a database:

  1. Use Sybase Central to connect to your file-based Web site.

  2. Open the Connections folder of the Web site.

  3. Create a connection to the database you want to retrieve data.

  4. Right-click on the root folder of your file-based Web site and select Properties.

  5. Select the connection that you just created from the pull down menu of the Connection field.

  6. Click OK.


Alternatively, you can create DynaScript connections in your Web documents to connect to a database and retrieve data. The following script uses the connection myConn (connects to the sample database) to execute a SQL query.

<HTML>
<TITLE>testthis.stm</TITLE>
<BODY>
<H1></H1>
<!--SCRIPT
myConn = site.GetConnection("Conn1");
if( myConn == null ) {
myConn = site.CreateConnection("Conn1", "My test connection", "Adaptive Server Anywhere 5.0 Sample", "dba", "sql");
}
-->
<!--SQL CONNECTION_OBJECT=myConn
SELECT contact.last_name, contact.first_name, contact.title
FROM DBA.contact contact

-->
<TABLE BORDER>
<TR>
<TH>last_name</TH>
<TH>first_name</TH>
<TH>title</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
</BODY>
</HTML>

Creating a connection profile for your Web site

You should create a connection profile for your Web site from Sybase Central. When you create a connection profile, the connection information is stored in the registry in encrypted form. This information is used not only in Sybase Central, but also by the Dynamo application server as database provider profiles.

There are three types of connection profiles that you may create:

Note  

Consistency with connections
A Web site should always be connected to with the same type of connection as was used for the original creation of the site. For example, if the sample Web site was created with an ODBC connection, it should not later be connected to with an Open Client connection

Steps To create a connection profile:

  1. From Sybase Central, select Tools | Connection Profiles. The Connection Profiles window is displayed.

  2. Click New. The Create New Profile window is displayed.

  3. Enter a name for the connection profile, and select PowerDynamo from the list of available types. Click OK. The Connection window displays.

  4. Select a connection type.




Note  

The Select Method
When you are creating an ODBC data source for an Adaptive Server Enterprise database the Select Method must be set to 0 - Cursor for Dynamo to work. The Select method setting is located within the ODBC Administrator | ODBC Sybase | Driver Setup | Performance Tab.

Regenerating a Web site

When you regenerate a Web site, the existing content of the Web site is deleted, and a new Web site is created.

Steps To regenerate a Web site:

  1. With the right mouse button, click the Web site icon in the left pane of Sybase Central, and select Regenerate from the menu.

  2. Enter a name for the main contents folder in the Web site setup window, and select the appropriate options to include the Dynamo documentation and sample application in the site. Click OK to regenerate a clean Web site.


WARNING!

Caution
Regenerating a Web site deletes the entire content of the Web site. This action cannot be undone.

Deleting a Web site

When you delete a Web site, the existing content of the Web site is deleted. If the database containing your Web site has other data, it is not affected by the deletion of the Web site. Also, the database itself is not deleted.

With the right mouse button, click the Web site icon in the left pane of Sybase Central, and select Delete from the menu.

WARNING!

Caution
Deleting a Web site deletes the entire content of the Web site. This action cannot be undone.

 


Copyright © 1999 Sybase, Inc. All rights reserved.