dbServ

How to use dbServ
For the HTML output you need special templates with some new tags for the database datas. For teh interpretation of the templates you have to call them in a special way:

  • Output:
    HREF="http://localhost:4444/out?template=adr/adraend.shtml"
    The host is called on a separete port (default 4444). Only 'out' with some parameters ('template=...') is used as document.
  • Input:
    HREF="http://localhost:4444/in?template=adr/adrupd.shtml"
    Change the database starts with 'in'. The client will bring you the parameters from a FORM. See also How it works.

new tags
dburltells the database
dbschemaadd a database schema if needed
dbuserthe database user
dbpasswdthe password
These tags are not printed in the html output.
All these informations are placed in the document header.
<dbstmt>
</dbstmt>
These tags include the SQL statement. With out templates the incoming parameters are added to the sql statement.
The server gets e.g. 'id_=100', so the where clause is updated with this. This works with ORDER BY or GROUP BY as well. All variable SQL where clause arguments are not defined in the script.

At the in statement the field values must be marked like '##field##'.
E.g. you like to change a name so your statement contains something like this 'set name_ = ##name_##'. The reference 'name_' comes from the parameter as 'name_=TheName' and is inserted by the server.
Sometimes you have to update numerical values in a text field (e.g. ZIP code). Then you have to define this at the input variable 'xx,c' (e.g. ##plz_,c## see also adrupd.shtml).
Some big text streams also make problems when they are defined as string. Therefore you mark it up as ASCII stream (e.g. ##longtext_,a## see adrupd.shtml).

<dbcall>
</dbcall>
In these tags you call a stored procedure.
See also How it works.
dbmaxrowHow many row do you want to see?
dbincludeCall an external text stream.
<dbdata>
</dbdata>
Between these tags you find the database output. While the database is fetching this action will be repeated. Fill in a reference like '##name_##' the server will fill it with the value of 'name_'. Sometimes it is easier to fill in the field number '##1##' for the first value and so on.
<dbdata txt="no data">You may define a text which is shown when there is no data.
<dbbreak col=???>
</dbbreak>
Group your output with 'dbBreak', you need a field to group on. Inside these tags the other datas are shown. You may use 'dbBreak' more than one time.
<dbbreak typ=mail col=???>
</dbbreak>
A special way of sending mail. All inside values and texts are going out.
In debug mode the output is written to the standard out. If you do not define a mailhost the output will go to the HTML output.
<dbmailto=???>
<dbmailsubject=???>
Use this to fill the mail information.
dbsubInserts another database query to your script. Don't use it inside the 'dbdata' tags.
##dbrownum##dbrownum is a special variable to show the row number. Use it like a field value.
##dbrowplus##dbrowplus is dbrownum plus one.
##dbrowminus##dbrowminus is dbrownum minus one.
##dbswaprow txt1="???" txt2="???"##dbswaprow is a design tool.
##dbtan##dbtan brings back a transaction number. For the first time activate the number with zero ('dbtan=0'). In the following scripts the transaction number has to be included. So the server validates the incoming datas for its correctness. Set the life time in the ini file.
dbtanrequiredTells the page that a dbtan is required.
dbfirstrow
dbnextrow
Here you tell your output datas to start with a defined row. E.g. <INPUT TYPE=HIDDEN NAME=dbfirstrow VALUE="5"> starts with the fifth line.
&dbvar=???;
dbfirstrow
dbnextrow
dbprevrow
dblastrow
This is an extra way to define your datas. Don't use it inside the <dbdata> tags. E.g. <INPUT TYPE=HIDDEN NAME=dbfirstrow VALUE="&dbvar=dbprevrow;"> fills in the previous row number. It is available from 'dbfirstrow' and 'dbmaxrow'. When 'dbfirstrow' value is 4 and 'dbmaxrow' value is 3, then 'dbprevrow' comes back with 1. (see example liste.shtml)
'dblastrow' shows the last visible row.
<dbnocache>Put this in your document header if you don't want it to be cached.
##dbnow##dbnow prints out the date. A call with 'form' prints the date formatted. Sample: ##dbnow form="MM.yy"## gives back month and yeat. Please use the Java rules for formatted dates.
dbprocesswriterdbprocesswriter sets a different writer only for this template. Place this on template top. E.g. <!-dbprocesswriter="de.dbServ.writer.dbMyWriter"-> changes the default dbSimpleWriter

Specials

Some special things when using databases:

  • Some database systems have an automatic counter when you are inserting a new row (e.g. Access uses COUNTER). If you don't have this option you may use the following action:
    Define a field with the name 'id_' in your table. Fill this in your input form as hidden field
    <INPUT TYPE=HIDDEN NAME=adr.id_ VALUE="-1">
    
    Then a row is added with the next id_ (see dbins.htm).

  • Select boxes can contain a list of values in it (see dbList.htm).

  • In form windows you often use images instead of buttons to design your sheet (<INPUT TYPE=image ...>). When you click the image the client gives you back the X and Y values. When the server generates the SELECT statement this is not very useful (...AND X=5 AND Y=12) when your table doesn't contain this fields. In dbServ you drop this in the ini file and now you are able to use image buttos (see dbList.htm).

  • Sometimes it is nice to give the user some help for the search. Not everybody knows about sql statements, here is an answer:
    <INPUT TYPE="text" NAME="name_[%]"  size=30>
    
    The server now adds the '%' character to the sql statement ('name_ like 'xxx%'). See How it works.

Additional functions with JavaScript

With the new tags for dbServ you have an easy way to get a useful database output but not everything is done with the server when you design a HTML application. So use JavaScript to get the rest. For example you have to fill a select box with the available datas but only one of the values belongs to your customer. Tell JavaScript to select the correct item of the list. (see 'setSelect.js' in the script 'adraend.shtml' and 'kunde2select').


The initialisation

All initialisation for dbServ is stored in the file dbServ.ini.
What to do:
logName of the log file
debugName of the debug file
errorName of the error file
bloguse log or not
bdebugdebug the statements
berrorerror file on or off
use_xyUse the x/y values or not.
use_guiShow the little server gui.
pubYour public path
tanaliveLife circle for the transaction in minutes
adminName of the administrator
passwdPassword for the administrator
counturldatabase url for the counter database
counttimeLife time for the counter image in seconds (0 = nocache)
countdateformatDate format for the counter db
counttimeformatTime format for the counter db
mailhostName of your mail host
mailfromThe mail sender
cachedirCache directory
cachealiveLifetime for your cache files. Set this to zero for no cache.
writersets the default writer
[driver]The list for your database drivers
com.mm.mysql.Driversample

Axel Fischer, afischer@dbServ.de
home