~roger-booth/rwboxy/main

« back to all changes in this revision

Viewing changes to controller/jsdbc/public_docs/dbcjs_wp/dbcjs_wpnode3.html

  • Committer: Roger Booth
  • Date: 2009-04-02 05:18:46 UTC
  • Revision ID: roger.booth@gmail.com-20090402051846-drud06q7qbymimwj
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
2
 
 
3
<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
 
4
original version by:  Nikos Drakos, CBLU, University of Leeds
 
5
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
 
6
* with significant contributions from:
 
7
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
 
8
<HTML>
 
9
<HEAD>
 
10
<TITLE>Example Walk-Through</TITLE>
 
11
<META NAME="description" CONTENT="Example Walk-Through">
 
12
<META NAME="keywords" CONTENT="jsdbc_wp">
 
13
<META NAME="resource-type" CONTENT="document">
 
14
<META NAME="distribution" CONTENT="global">
 
15
 
 
16
<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
 
17
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
 
18
 
 
19
<LINK REL="STYLESHEET" HREF="jsdbc_wp.css">
 
20
 
 
21
</HEAD>
 
22
 
 
23
<BODY >
 
24
 
 
25
<H1><A NAME="SECTION00030000000000000000"></A>
 
26
<A NAME="s1:demo"></A>
 
27
<BR>
 
28
Example Walk-Through
 
29
</H1>
 
30
 
 
31
<P>
 
32
 
 
33
<DIV ALIGN="CENTER"><A NAME="fig:demo1_login"></A><A NAME="113"></A>
 
34
<TABLE>
 
35
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 2:</STRONG>
 
36
Demo Login Page</CAPTION>
 
37
<TR><TD>
 
38
<DIV ALIGN="CENTER">
 
39
 
 
40
</DIV><IMG
 
41
  WIDTH="500" HEIGHT="455" ALIGN="BOTTOM" BORDER="0"
 
42
 SRC="./demo_login.gif"
 
43
 ALT="Image demo_login">
 
44
 
 
45
<P></TD></TR>
 
46
</TABLE>
 
47
</DIV>
 
48
 
 
49
<P>
 
50
The <SMALL>DBC-JS</SMALL> API consists of three objects:
 
51
 
 
52
<OL>
 
53
<LI><SPAN  CLASS="textbf"><SMALL>RDB</SMALL></SPAN>, corresponding to a database (or connection) handle.
 
54
</LI>
 
55
<LI><SPAN  CLASS="textbf"><SMALL>RDBSTATEMENT</SMALL></SPAN>, corresponding to a statement handle.
 
56
</LI>
 
57
<LI><SPAN  CLASS="textbf"><SMALL>RDBEXCEPTION</SMALL></SPAN>, thrown when <SMALL>DBC-JS</SMALL> detects an error.
 
58
</LI>
 
59
</OL>
 
60
 
 
61
<P>
 
62
<TT>demos/runsql.html</TT> is a minimalistic demonstration of the <SMALL>DBC-JS</SMALL> API.
 
63
The application consists mostly of JavaScript functions that build the web-page
 
64
and exercise the <SMALL>DBC-JS</SMALL> API.  The DOM API is used to create and modify the
 
65
demo's web-pages.
 
66
 
 
67
<P>
 
68
Using <TT>createLoginPage()</TT>, the demo first creates and displays a
 
69
login-page (see Figure&nbsp;<A HREF="#fig:demo1_login">2</A>) into which a user enters the data
 
70
source name, user name and password, and the url to the <SMALL>DBC-JS</SMALL> gateway.  The
 
71
demo then checks (in <TT>submitLogin()</TT>) - by trying to create a
 
72
corresponding <SPAN  CLASS="textbf"><SMALL>RDB</SMALL></SPAN> instance - whether the user is authorized to access the
 
73
specified data source.  If she is, the demo first saves the login-form
 
74
information, and then uses <TT>createSQLPage()</TT> to replace the login-page
 
75
with an execute-sql page.  If the user cannot be authenticated (an exception is
 
76
caught), an error message is inserted in the login-page.
 
77
 
 
78
<P>
 
79
 
 
80
<DIV ALIGN="CENTER"><A NAME="fig:demo1_results"></A><A NAME="126"></A>
 
81
<TABLE>
 
82
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 3:</STRONG>
 
83
Demo Query Results Page</CAPTION>
 
84
<TR><TD>
 
85
<DIV ALIGN="CENTER">
 
86
 
 
87
</DIV><IMG
 
88
  WIDTH="500" HEIGHT="455" ALIGN="BOTTOM" BORDER="0"
 
89
 SRC="./demo_results.gif"
 
90
 ALT="Image demo_results">
 
91
 
 
92
<P></TD></TR>
 
93
</TABLE>
 
94
</DIV>
 
95
 
 
96
<P>
 
97
The execute-sql page allows the user to enter an <SMALL>SQL</SMALL> statement that will be
 
98
executed on the database server.  Any <SMALL>SQL</SMALL> statement - not only queries - can
 
99
be executed.  This is implemented in <TT>executeSQL()</TT>, where the demo:
 
100
 
 
101
<OL>
 
102
<LI>creates an <SPAN  CLASS="textbf"><SMALL>RDB</SMALL></SPAN> instance,
 
103
</LI>
 
104
<LI>creates a <SPAN  CLASS="textbf"><SMALL>RDBSTATEMENT</SMALL></SPAN> via <TT>RDB.prepare()</TT>,
 
105
</LI>
 
106
<LI>executes the <SMALL>SQL</SMALL> via <TT>RDBStatement.execute()</TT>.
 
107
</LI>
 
108
<LI>displays the columns of a query's result-set via
 
109
  <TT>RDBStatement.columnNames()</TT>: the result-set itself (in
 
110
  <TT>createTableHead()</TT> and <TT>createTableBody()</TT>) is displayed using
 
111
  <TT>RDBStatement.fetch()</TT>.
 
112
</LI>
 
113
</OL>
 
114
 
 
115
<P>
 
116
As shown in Figure&nbsp;<A HREF="#fig:demo1_results">3</A>, the results of the <SMALL>SQL</SMALL> statement
 
117
(whether valid or invalid) are displayed to the user who can then execute
 
118
further statements.  With respect to error checking, note how the demo wraps
 
119
invocations of the <SMALL>DBC-JS</SMALL> API with a <TT>try/catch</TT> of <SPAN  CLASS="textbf"><SMALL>RDBEXCEPTION</SMALL></SPAN>: if
 
120
this exception occurs, its state is passed to <TT>setStatus()</TT> which
 
121
displays an error message (Figure&nbsp;<A HREF="#fig:demo1_error">4</A>).
 
122
 
 
123
<P>
 
124
 
 
125
<DIV ALIGN="CENTER"><A NAME="fig:demo1_error"></A><A NAME="145"></A>
 
126
<TABLE>
 
127
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 4:</STRONG>
 
128
Demo Error Report Page</CAPTION>
 
129
<TR><TD>
 
130
<DIV ALIGN="CENTER">
 
131
 
 
132
</DIV><IMG
 
133
  WIDTH="500" HEIGHT="387" ALIGN="BOTTOM" BORDER="0"
 
134
 SRC="./demo_error.gif"
 
135
 ALT="Image demo_error">
 
136
 
 
137
<P></TD></TR>
 
138
</TABLE>
 
139
</DIV>
 
140
 
 
141
<P>
 
142
<BR><HR>
 
143
<ADDRESS>
 
144
Administrator
 
145
2007-03-27
 
146
</ADDRESS>
 
147
</BODY>
 
148
</HTML>