If you want to know more about connecting web sites to databases then read Philip and Alex's Guide to Web Publishing.
The examples here assume that you followed our AOLserver installation instructions. But the process should still be simple if you managed to install AOLserver yourself.
We will work through the installation of Solid and then setup AOLserver to talk to the Solid database. The setup of Solid is trivial. If you are a complete maniac then try installing Oracle. The best comparison is that Solid is a 2MB download, compared to 140MB for Oracle. This difficulty factor of 70 holds true throughout the installation of Oracle.
Solid is cheap, low maintenance and will be powerful enough for most web sites.
mkdir solid cd solid
tar xzvf sw23lux.tar
setup
Synop Software Synop User
nsadmin synop
Congratulations, your Solid database server is running. That took me a week with Oracle.
bin/solcon
SOLID Remote Control v.02.30.0026 (C) Copyright Solid Information Technology Ltd 1993-1998 Exit by giving command: exit Username: nsadmin Password: SOLID Server - v.02.30.0026 (Linux ix86) (C) Copyright Solid Information Technology Ltd 1993-1998 License for SOLID Web Engine v2.30, Standard Edition Evaluation License Serial number: 0000023023 Maximum number of connections: 20 Database age limit: 30 days Extensions: SMP, Server, JDBC Licensed to: Synop Software Synop User > help Available commands: backup bak Takes a backup copy of the database. backuplist bls Displays a status list of last backups. close clo Closes server connections, no new connections are allowed. errorcode ec Displays a description of an error code. exit ex Exits from SOLID Remote Control. help ? Displays this text. hotstandby hsb Executes hot standby command. makecp mcp Makes a checkpoint. messages mes Displays server messages. monitor mon Sets server monitoring on or off. open ope Opens server connections, new connections are allowed. report rep Generates a report of server info to a file. shutdown sd Stops SOLID Server. status sta Displays server statistics. throwout to Throws out users from SOLID Server. userlist ul Displays user list. version ver Displays server version info. > userlist User name: User id: Type: Machine id: Login time: NSADMIN 0 Solcon Local 31.10 02:39:40 > shutdown Server is shutting down, please wait... Server is shut down, exiting from SOLID Remote Control.
bin/solid -f -cdatabase/default
bin/solsql -fsamples/sample.sql
SOLID SQL Editor (teletype) v.02.30.0026 (C) Copyright Solid Information Technology Ltd 1993-1998 Execute SQL statements terminated by a semicolon. Exit by giving command: exit; Username: nsadmin Password: Connected to default server. --/****************************************************************\ --** filename * sample.sql --** description * Table, index, role and user creation samples. --** Copyright (C) Solid Information Technology Ltd 1997 --\****************************************************************/ -- First create table TEST_TABLE CREATE TABLE TEST_TABLE ( ID INTEGER NOT NULL, TEXT VARCHAR, TODAY DATE, VALUE FLOAT, PRIMARY KEY(ID) ) Command completed successfully, 0 rows affected. -- Statements are ended with a semicolon. -- Create another table named PROD_TABLE CREATE TABLE PROD_TABLE ( ID INTEGER NOT NULL UNIQUE, TEXT VARCHAR, TODAY DATE, VALUE FLOAT, PRIMARY KEY (ID) ) Command completed successfully, 0 rows affected. -- Create few users CREATE USER CALVIN IDENTIFIED BY HOBBES Command completed successfully, 0 rows affected. CREATE USER DIANE IDENTIFIED BY PASSWO1 Command completed successfully, 0 rows affected. CREATE USER JILL IDENTIFIED BY PASSWO2 Command completed successfully, 0 rows affected. CREATE USER MARK IDENTIFIED BY PASSWO3 Command completed successfully, 0 rows affected. CREATE USER JAKE IDENTIFIED BY PASSWO4 Command completed successfully, 0 rows affected. -- Change Jakes password to ELWOOD ALTER USER JAKE IDENTIFIED BY ELWOOD Command completed successfully, 0 rows affected. -- Delete user Calvin DROP USER CALVIN Command completed successfully, 0 rows affected. -- Create TESTERS and PRODUCTION roles CREATE ROLE TESTERS Command completed successfully, 0 rows affected. CREATE ROLE PRODUCTION Command completed successfully, 0 rows affected. -- Grant rights for these roles GRANT INSERT, SELECT ON TEST_TABLE TO TESTERS Command completed successfully, 0 rows affected. GRANT INSERT, SELECT, DELETE ON PROD_TABLE TO PRODUCTION Command completed successfully, 0 rows affected. -- Grant roles to users. -- Diane and Mark are testers while the others are production users. GRANT TESTERS TO DIANE Command completed successfully, 0 rows affected. GRANT TESTERS TO MARK Command completed successfully, 0 rows affected. GRANT PRODUCTION TO JILL Command completed successfully, 0 rows affected. GRANT PRODUCTION TO JAKE Command completed successfully, 0 rows affected. -- Grant Diane right to delete from test_table GRANT DELETE ON TEST_TABLE TO JILL Command completed successfully, 0 rows affected. -- Grant Mark Production role GRANT PRODUCTION TO MARK Command completed successfully, 0 rows affected. -- Revoke the delete right from Jill on PROD_TABLE REVOKE DELETE ON PROD_TABLE FROM JILL Command completed successfully, 0 rows affected. -- Revoke the PRODUCTION role from JAKE REVOKE PRODUCTION FROM JAKE Command completed successfully, 0 rows affected. -- Revoke the delete right on table TEST_TABLE from TESTERS role. REVOKE DELETE ON TEST_TABLE FROM TESTERS Command completed successfully, 0 rows affected. -- Grant Jill the system administrator role. Jill will have all -- rights to all tables (except the system tables) from now on. GRANT SYS_ADMIN_ROLE TO JILL Command completed successfully, 0 rows affected. -- Drop the GUEST_USERS role. When this role is dropped all users -- granted this role have their rights removed. DROP ROLE TESTERS Command completed successfully, 0 rows affected. -- Make the changes to tables, users and roles -- permanent by committing the work we have done. -- If the autocommit set to ON, this has no effect. COMMIT WORK Command completed successfully, 0 rows affected. -- Now we modify the tables and create few indexes. -- Add another column to table TEST_TABLE ALTER TABLE TEST_TABLE ADD COLUMN C CHAR(1) Command completed successfully, 0 rows affected. COMMIT WORK Command completed successfully, 0 rows affected. -- Delete the added column ALTER TABLE TEST_TABLE DROP COLUMN C Command completed successfully, 0 rows affected. -- Create a non-unique index on column ID to TEST_TABLE CREATE INDEX X_TEST ON TEST_TABLE (ID) Command completed successfully, 0 rows affected. -- Create a unique index on column VALUE to TEST_TABLE CREATE UNIQUE INDEX UX_TEST ON TEST_TABLE (VALUE) Command completed successfully, 0 rows affected. -- Drop the non-unique index DROP INDEX X_TEST Command completed successfully, 0 rows affected. -- And again commit the work we have done. COMMIT WORK Command completed successfully, 0 rows affected. SOLID SQL Editor exiting.
The first step is to insert the sample table into the database. The given sql code does not contain a commit work instruction and so we must instruct the sql editor to automatically commit every line if we want the table to be permanent, hence the -a option.
The Solid distribution 2.30.0026 for Linux contains an error in cgitest.c. Line 44 of this file must be changed to use UCHAR * not char *. If you run make this error will be reported and the change is obvious. If you get an error from the cgitest.run program saying that it couldn't connect, or couldn't verify the user then you have done something wrong.
bin/solsql -a -fsamples/cgi_c/cgitest.sql cd samples/cgi_c edit cgitest.c line 44
static void process_SQL_statement( HENV henv, HDBC hdbc, HSTMT hstmt, char* statement); static void process_SQL_statement( HENV henv, HDBC hdbc, HSTMT hstmt, UCHAR* statement);
make cgitest.run
Content-type: text/html <!DOCTYPE HTML PUBLIC><HEAD><TITLE> CGI-bin Result Page </TITLE></HEAD><BODY><CENTER><H1 ALIGN=CENTER> Email Addresses with Name like "NO*" </H1></CENTER><CENTER><TABLE BORDER=1 ALIGN=CENTER> <TR> <TD>NAME</TD> <TD>EMAIL</TD> </TR> </TABLE></CENTER></BODY>
bin/solsql
SOLID SQL Editor (teletype) v.02.30.0026 (C) Copyright Solid Information Technology Ltd 1993-1998 Execute SQL statements terminated by a semicolon. Exit by giving command: exit; Username: nsadmin Password: Connected to default server. help; SOLID SQL Editor executes SQL statements; SQL statements must be terminated by a semicolon (;). To quit give command quit terminated by a semicolon. select * from test_table; ID TEXT TODAY VALUE -- ---- ----- ----- 0 rows fetched. select * from tables; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE REMARKS ------------- ------------ ---------- ---------- ------- NULL _SYSTEM SYS_TABLES BASE TABLE NULL NULL _SYSTEM SYS_COLUMNS BASE TABLE NULL NULL _SYSTEM SYS_USERS BASE TABLE NULL NULL _SYSTEM SYS_UROLE BASE TABLE NULL NULL _SYSTEM SYS_RELAUTH BASE TABLE NULL NULL _SYSTEM SYS_ATTAUTH BASE TABLE NULL NULL _SYSTEM SYS_VIEWS BASE TABLE NULL NULL _SYSTEM SYS_KEYPARTS BASE TABLE NULL NULL _SYSTEM SYS_KEYS BASE TABLE NULL NULL _SYSTEM SYS_CARDINAL BASE TABLE NULL NULL _SYSTEM SYS_INFO BASE TABLE NULL NULL _SYSTEM SYS_SYNONYM BASE TABLE NULL NULL _SYSTEM TABLES VIEW NULL NULL _SYSTEM COLUMNS VIEW NULL NULL _SYSTEM SQL_LANGUAGES BASE TABLE NULL NULL _SYSTEM SERVER_INFO VIEW NULL NULL _SYSTEM SYS_TYPES BASE TABLE NULL NULL _SYSTEM SYS_FORKEYS BASE TABLE NULL NULL _SYSTEM SYS_FORKEYPARTS BASE TABLE NULL NULL _SYSTEM SYS_PROCEDURES BASE TABLE NULL NULL _SYSTEM SYS_TRIGGERS BASE TABLE NULL NULL _SYSTEM SYS_TABLEMODES BASE TABLE NULL NULL _SYSTEM SYS_EVENTS BASE TABLE NULL NULL _SYSTEM SYS_SEQUENCES BASE TABLE NULL NULL _SYSTEM SYS_TMP_HOTSTANDBY BASE TABLE NULL NULL NSADMIN PARTNERS BASE TABLE NULL NULL NSADMIN TEST_TABLE BASE TABLE NULL NULL NSADMIN PROD_TABLE BASE TABLE NULL 28 rows fetched. select * from sys_users; ID NAME TYPE PRIV PASSW PRIORITY -- ---- ---- ---- ----- -------- 1 NSADMIN USER 1 73ADA120B31AF4 NULL 2 CGITEST USER 0 CCEA881A19783A NULL 4 DIANE USER 0 FC6D49C3F857D7 NULL 5 JILL USER 1 1310BB69BFC314 NULL 6 MARK USER 0 969C68D13E018A NULL 7 JAKE USER 0 7789B462C68910 NULL 9 PRODUCTION ROLE 0 NULL NULL 7 rows fetched. quit; SOLID SQL Editor exiting.
Again, distribution 2.30.0026 contains an error here. The makefile given is for the previous version 2.2 and needs to be changed to reference the include files for version 2.3. The adhoc program is similar to the solsql program, it simply allows you to make adhoc queries to the database.
cd ~/solid/samples/sqlapi_c edit makefile line 31 VER=22 VER=23 make adhoc
bin/solcon
SOLID Remote Control v.02.30.0026 (C) Copyright Solid Information Technology Ltd 1993-1998 Exit by giving command: exit Username: nsadmin Password: SOLID Server - v.02.30.0026 (Linux ix86) (C) Copyright Solid Information Technology Ltd 1993-1998 License for SOLID Web Engine v2.30, Standard Edition Evaluation License Serial number: 0000023023 Maximum number of connections: 20 Database age limit: 30 days Extensions: SMP, Server, JDBC Licensed to: Synop Software Synop User > shutdown Server is shutting down, please wait... Server is shut down, exiting from SOLID Remote Control.
GET /cgi-bin /home/nsadmin/solid/samples/cgi_c POST /cgi-bin /home/nsadmin/solid/samples/cgi_c
ACTION="http://internal.synop.com/cgi-bin/cgitest.cgi"
We can see that this is simply a program which performs this query on the database:
SELECT * FROM WHERE NAME LIKE 'S%'
Congratulations, you have just set up a database backed web site.
Driver: intsol Connections: 5 Data Source: TCP/IP internal.synop.com 1313 User: nsadmin Password: synop Verbose: On Log SQL Errors: On Extended Table Info: On
/web/synop/www
cp /home/nsadmin/solid/samples/cgi_c/cgitest.htm /web/synop/www/tcltest.html
Now edit that file and change the action to be tcltest.tcl. The line should now look like this (link removed):
</CENTER><FORM METHOD="post" ACTION="tcltest.tcl">
This means that the tcl script stored in tcltest.tcl will be run to handle the information from the script. Open the html file in your browser to test it:
http://internal.synop.com/tcltest.html or file:/web/synop/www/tcltest.html
ns_return 200 text/plain "testing"
This tells AOLserver to return the string testing to the client with a return code of 200 and the mime type text/plain. The browser should return testing if you go to the URL:
http://internal.synop.com/tcltest.tcl
You can test your tcltest.html file by clicking on submit, again it should say testing.
# get the value of the name parameter set formdata [ns_conn form $conn] set name [ns_set get $formdata Name] # open a connection to the database set db [ns_db gethandle solidpool] # perform the query set row [ns_db select $db "select name, email from partners where name like [ns_dbquotevalue $name%]"] # set up the html set html " <html> <body> <table border=1> <tr><td>Name</td><td>Email</td>" # get the rows returned by the query and insert them in the table while { [ns_db getrow $db $row] } { append html " <tr><td>[ns_set get $row name]</td><td>[ns_set get $row email]</td></tr>" } # finish the html append html " </table> </body> </html>" # return it all to the user ns_return 200 text/html $html
<html> <body> <table border=1> <tr><td>Name</td><td>Email</td> <% # get the value of the name parameter set formdata [ns_conn form $conn] set name [ns_set get $formdata Name] # open a connection to the database set db [ns_db gethandle solidpool] # perform the query set row [ns_db select $db "select name, email from partners where name like [ns_dbquotevalue $name%]"] # set up the rows while { [ns_db getrow $db $row] } { append html " <tr><td>[ns_set get $row name]</td><td>[ns_set get $row email]</td></tr>" } # release the database handle back to the pool ns_db releasehandle $db # print out the rows ns_puts $html %> </table> </body> </html>
The Solid evaluation license limits the life of any database file to 30 days maximum. To create a new database all you have to do is delete the out of date database file. Go to solid/database/default and delete the file solid.db. Of course, all information in the deleted database file will be lost.
To delete the file:
cd /home/nsadmin/solid/database/default rm solid.db
To start the database up again:
cd cd solid bin/solid -f -cdatabase/default
SOLID Server - v.02.30.0026 (Linux ix86) (C) Copyright Solid Information Technology Ltd 1993-1998 Using license file /home/nsadmin/solid/database/default/solid.lic License for SOLID Web Engine v2.30, Standard Edition Evaluation License Serial number: 0000023023 Maximum number of connections: 20 Database age limit: 30 days Extensions: SMP, Server, JDBC Licensed to: Synop Software Synop User Current working directory changed to database/default Using configuration file /home/nsadmin/solid/database/default/solid.ini Database does not exist. Do you want to create a new database (y/n)? y Give username and password for database administrator. Username: nsadmin Password: Retype password: Creating a new database, please wait ... Listening of 'UPipe SOLID' started. Listening of 'TCP/IP 1313' started. SOLID Server started at Sat Oct 31 02:34:14 1998