_Web-Database Connectivity_
by Z. Peter Lazar
Listing One
Initial LiveWire Page
List Generated Dynamically from Database Using LiveWire
Click here to generate a list of
hyperlinks from the TOPIC table.
Listing Two
///////////////////////////////////////////////////////////////////////////
// lw_topic.htm - LiveWire Implementation
//
// This page displays displays a list of interests from the TOPIC table.
// The descriptions are hyperlinked. If you click on an interest, the
// following page will display an associated list of sub-interests taken
// from the SUBTOPIC table.
///////////////////////////////////////////////////////////////////////////
Your Interests
Select a Topic Which Interests You:
if ( database.connected() ) {
database.beginTransaction();
qs = "SELECT topic_id, topic_desc from TOPIC";
results = database.cursor( qs );
while(results.next())
{
write( "- "+results.topic_desc+"\n");
}
results.close();
database.commitTransaction();
}
else {
write("
Database connection failed");
}
Listing Three
///////////////////////////////////////////////////////////////////////////
// project.html - LiveWire Implementation
//
// Project file for INTEREST application
///////////////////////////////////////////////////////////////////////////
// Establish a Connection to the INTEREST Database for ALL Clients
if ( !database.connected() ) {
project.lock();
database.connect("ODBC","PROTO","admin","","");
if(!database.connected()) {
write("Database connection failed");
}
project.unlock();
}
Listing Four
Initial Cold Fusion Page
List Generated Dynamically from Database Using Cold Fusion
Click here to generate a list of hyperlinks
from the TOPIC table.
Listing Five
Your Interests
Select a Topic Which Interests You:
SELECT TOPIC.topic_id,TOPIC.topic_desc,TOPIC.topic_id
FROM TOPIC
#topic_desc#">
Listing Six
Initial Sapphire Page
List Generated Dynamically from Database Using Sapphire/Web
Click here to generate a list of hyperlinks from
the TOPIC table.
Listing Seven
Your Interests
Select a Topic Which Interests You:
##Sa_MasDetHotListSite##TEMP
Listing Eight
#include "SaRnHtml.h"
#include
/* Sapphire Start Of User Includes */
/* Sapphire End Of User Includes */
/* Sapphire Start Of Callback Declarations */
extern void R_Sapphire_html ();
extern void R_sw_topic_html ();
/* Sapphire End Of Callback Declarations */
#ifdef _NO_PROTO
int SaCartInit(argc, argv)
int argc;
char *argv[];
#else
int SaCartInit(int argc, char *argv[])
#endif
{
/* Sapphire Start Of Initial Code */
/* Sapphire End Of Initial Code */
SaInitClient(&argc, argv);
/* Sapphire Start Of Callback Registration */
R_Sapphire_html ();
R_sw_topic_html ();
SaInitHeaders();
SaRelocatableProject(0);
SaSetDefaults("","");
SaSetStartupHtml("home.html");
SaSetHtmlURL("http://ORDSYS2:80/interest");
SaSetApiMaxNum(250);
SaAllowShutDown(1);
SaSetCacheNumConn(2);
SaSetSessTimeOut(1200);
SaSetGifURL("");
SaSetDefaultVendor(SGENODEFAULT);
SaSetOrbHost("");
SaSetKOption(223046);
SaSetDefaultUser("admin");
SaSetDefaultPass("");
SaAllowSQL(0);
SaAllowConfigFile(0);
SaSetConfigFile("/Sapphire/config/interest.cfg");
SaSetHtmlDir("C:\\www\\data\\interest");
SaSetPrintArgs(0);
SaSetPrintEnv(0);
SaProcessLogin(1);
SaSetDoCommonLog(0);
SaSetUseAppLogin(0);
SaSetStateHost("");
/* Sapphire End Of Callback Registration */
/* Sapphire Start Of Final Code */
/* Sapphire End Of Final Code */
SaProcessInputStream();
return 0;
}
#ifdef _NO_PROTO
int SAMAIN_DECL main(argc, argv)
int argc;
char *argv[];
#else
int SAMAIN_DECL main(int argc, char *argv[])
#endif
{
SaRegisterReq(SaCartInit);
SaParseCommmandLine(argc, argv);
return 0;
}
#ifdef WRB
#ifdef _WINDOWS
#undef u_long
#include
#ifdef __cplusplus
extern "C" {
#endif
BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called,
LPVOID lpReserved)
{
return 1;
UNREFERENCED_PARAMETER(hInst);
UNREFERENCED_PARAMETER(ul_reason_being_called);
UNREFERENCED_PARAMETER(lpReserved);
}
extern int SaInitCartNT(void* WRBCalls);
_declspec (dllexport)
int SaInitCart (void* WRBCalls)
{
return SaInitCartNT(WRBCalls);
}
#ifdef __cplusplus
}
#endif
#endif
#endif
Listing Nine
/* Sapphire Module File V1.0B */
/* Sapphire Start Of Tool Includes */
#include "SaRnHtml.h"
/* Sapphire Start Of user Includes */
static char _Sa_HTML_Filename[] = "Sapphire.html";
/*Sapphire Start of Function */
static void AGO ()
/* start of initial code */
{
/* start of func Code */
{
/** sapphire versn 1.00 **/
XtPointer SaClient=NULL;
{
pSgeWorkCallData pSgeWCD;
extern void SaPopulateHotList SUTPROTO((Widget,
XtPointer, SaCallbackStruct*));
/********************************************************/
/********* users initial code is inserted here **********/
/********************************************************/
/***** Begin Site Registry Code *****/
/***** End of Site Registry Code *****/
pSgeWCD = getSgeWorkCallData(UxWidget,
-1,
"PROTO",
"PROTO",
"TOPIC", NO_WP);
SgeSetCallDetail(pSgeWCD, NO_CACHE,
(XtPointer)0x0,
ROW_INDEX, (XtPointer)0x0,
(XtPointer)0x0,
NO_QUEUE_FILE);
SgeSetColBind(pSgeWCD, "sw_topic.html|MasDetHotListSite", 1, 0, 4,
(XtPointer)SaPopulateHotList,
(void *) 0);
SgeSetColDetail(pSgeWCD, 4, 0, 0, 0,
"LONG",
"topic_id");
SgeSetColBind(pSgeWCD, "sw_topic.html|MasDetHotListSite", 1, 0, 220,
(XtPointer)0x0,
(XtPointer)0x0);
SgeSetColDetail(pSgeWCD, 12, 0, 0, 0,
"TEXT",
"topic_desc");
SgeVaSetFrags(pSgeWCD,
"SELECT \
[TOPIC].[topic_id], \
[TOPIC].[topic_desc] \
FROM \
[TOPIC]",
VULL);
/* db-UIM/X Bind Name : sw_topicdhtml1 */
DoWorkProc(pSgeWCD, PROCESSBRSREQUEST_XSQL);
/*******************************************************/
/********** users final code is inserted here **********/
/*******************************************************/
/*************** END OF SAPPHIRE FINAL CODE **********************/
}
}/* end of func code */
/* start of final code */
}/* end of final code */
void R_Sapphire_html()
{
SaRegisterHtmlActivator("GO__ASapphire_html",AGO);
}/* Sapphire End of Module */
Listing Ten
/* Sapphire Module File V1.0B */
/* Sapphire Start Of Tool Includes */
#include "SaRnHtml.h"
/* Sapphire Start Of user Includes */
static char _Sa_HTML_Filename[] = "sw_topic.html";
/*Sapphire Start of Function */
static void AGO ()
/* start of initial code */
{
/* start of func Code */
{
/** sapphire versn 1.00 **/
XtPointer SaClient=NULL;
{
pSgeWorkCallData pSgeWCD;
extern void SaPopulateListItem SUTPROTO((Widget,
XtPointer, SaCallbackStruct*));
/********************************************************/
/********* users initial code is inserted here **********/
/********************************************************/
/***** Begin Site Registry Code *****/
/***** End of Site Registry Code *****/
pSgeWCD = getSgeWorkCallData(UxWidget,
-1,
"PROTO",
"PROTO",
"SUBTOPIC", NO_WP);
SgeSetCallDetail(pSgeWCD, NO_CACHE,
(XtPointer)0x0,
ROW_INDEX, (XtPointer)0x0,
(XtPointer)0x0,
NO_QUEUE_FILE);
SgeSetColBind(pSgeWCD, (XtPointer)0x0, 1, 0, 220,
(XtPointer)SaPopulateListItem,
(void *) 0);
SgeSetColDetail(pSgeWCD, 12, 0, 0, 0,
"TEXT",
"subtopic_desc");
SgeVaSetFrags(pSgeWCD,
"SELECT \
[SUBTOPIC].[subtopic_desc] \
FROM \
[SUBTOPIC]",
VULL);
/* db-UIM/X Bind Name : sw_subtopicdhtml1 */
DoWorkProc(pSgeWCD, PROCESSBRSREQUEST_XSQL);
/*******************************************************/
/********** users final code is inserted here **********/
/*******************************************************/
/*************** END OF SAPPHIRE FINAL CODE ************************/
}
}/* end of func code */
/* start of final code */
}/* end of final code */
void R_sw_topic_html()
{
SaRegisterHtmlActivator("GO__Asw_topic_html",AGO);
}/* Sapphire End of Module */
Listing Eleven
Initial WebObjects Page
List Generated Dynamically from Database Using WebObjects
Click to generate a
list of hyperlinks from the TOPIC table.
Listing Twelve
NEXTPAGE: WOHyperlink {string = "here"; pageName = "wo_topic"; };
Listing Thirteen
Your Interests
Select a Topic Which Interests You:
Listing Fourteen
TopicList: WORepetition {item = topic; list = topics.allObjects; };
SubTopicPage: WOHyperlink {string = topic.topicDesc;
pageName = "wo_subtopic"; };
Listing Fifteen
id topic;
id topics;
Listing Sixteen
{
NameCounts = {WORepetition = 2; WOString = 4; };
Types = {};
encoding = NSWindowsCP1252StringEncoding;
variables = {
topic = {TypeName = Topic; };
topics = {
AutoInitialized = 1;
TypeName = Topics;
initialValue = {
class = WODisplayGroup;
dataSource = {
class = EODatabaseDataSource;
editingContext = session.defaultEditingContext;
fetchSpecification = {class = EOFetchSpecification;
entityName = Topic; isDeep = YES; };
};
fetchesOnLoad = YES;
formatForLikeQualifier = "%@*";
numberOfObjectsPerBatch = 0;
selectsFirstObjectAfterFetch = YES;
};
};
};
}
Listing Seventeen
{
attributes = (
{
allowsNull = Y;
columnName = date_time_stamp;
externalType = DATETIME;
name = dateTimeStamp;
valueClassName = NSCalendarDate;
},
{
allowsNull = Y;
columnName = topic_desc;
externalType = TEXT;
name = topicDesc;
valueClassName = NSString;
width = 220;
},
{
allowsNull = Y;
columnName = topic_id;
externalType = COUNTER;
name = topicId;
precision = 10;
valueClassName = NSNumber;
valueType = i;
},
{
allowsNull = Y;
columnName = topic_url;
externalType = TEXT;
name = topicUrl;
valueClassName = NSString;
width = 220;
},
{
allowsNull = Y;
columnName = userid;
externalType = TEXT;
name = userid;
valueClassName = NSString;
width = 10;
}
);
attributesUsedForLocking=(topicId,topicDesc,topicUrl,userid,dateTimeStamp);
classProperties = (topicId, topicDesc, topicUrl, userid, dateTimeStamp);
externalName = TOPIC;
name = Topic;
primaryKeyAttributes = (topicId);
}