HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Pathways' SilverStream Solution"
Volume: 4 Issue: 3, p. 36

	

Listing 1.
 
1. Hashtable queryInfo = new Hashtable(); 
2. 
3. String sUser = ""; 
4. String sPassword = ""; 
5. String ls_agency = ""; 
6. String sQuery = ""; 
7. String sAgencyName = ""; 
8. String sUserID = ""; 
9. BigDecimal bdAgencyKey = new BigDecimal(0); 
10. BigDecimal bdUserKey = new BigDecimal(0); 
11.  
12. // Retrieve the value of the login field and check to  
13. // ensure that user has entered at least one character 
14. sUser = FieldLogin.getValue(); 
15. if ( sUser.equals("")) 
16. { 
17. agScriptHelper.alert("You must enter a user id."); 
18. return ; 
19. } 
20.  
21. // Retrieve the value of the password field and check to  
22. // ensure that user has entered at least one character 
23. sPassword = FieldPassword.getValue(); 
24. if (sPassword.equals("")) 
25. { 
26.  agScriptHelper.alert("You must enter a password."); 
27.  return ; 
28. } 
29.  
30. //Build the query String for the Data Object 
31. sQuery = "USER_ID = '" + sUser + "'" + 
32.  " AND PASSWORD = '" + sPassword + "'" ; 
33.  
34. // Put information into a hashtable 
35. queryInfo.put("Query", sQuery); 
36. qureyInfo.put("Database",getDatabase()); 
37.  
38. try 
39. { 
40.  // Invoke the business object 
41.  String queryResult = (String) agpDataLogin.invokeQuery(queryInfo);  
42.  
43.  // Check to ensure that the object ran successfully 
44.  if (queryResult == null)  
45.   { 
46.   agScriptHelper.alert("Invalid Login, Please try again. (Null Query)"); 
47.   return ; 
48.   } 
49.  
50.  // Check to ensure that the data object returned a result set 
51.  if (queryResult.equals("1")) 
52.   { 
53.  
54.  // goto the first row in the result set 
55.  agpDataLogin.gotoFirst(); 
56.  
57.  // Get the User has been assigned to an Agency  
58.  bdAgencyKey = (BigDecimal) agpDataLogin.getProperty(0); 
59.  if (bdAgencyKey == null) 
60.  { 
61.   agScriptHelper.alert("Invalid Login, Please try again."); 
62.   return ; 
63.  } 
64.  
65.  // Retrieve the required fields from the data object 
66.  bdUserKey = (BigDecimal) agpDataLogin.getProperty(1); 
67.  sUserID = (String) agpDataLogin.getProperty(2); 
68.  sAgencyName = (String) agpDataLogin.getProperty(3); 
69. 
70.  // Set the session values for the application 
71.  setSessionValue("AgencyKey", bdAgencyKey.toString()); 
72.  setSessionValue("UserKey", bdUserKey.toString()); 
73.  setSessionValue("AgencyName", sAgencyName); 
74.  setSessionValue("UserID", sUserID); 
75.  setSessionValue("ClientKey", ""); 
76.  
77.  // Goto the applications main interface. 
78.  showPage("FrameSet.html"); 
79.  
80.  } 
81. else 
82.  { 
83.  agScriptHelper.alert("Error"); 
84.  System.out.println ("Error: Unable to access the Clients");  
85.  } 
86. } 
87. catch (Exception e) 
88. { 
89. agScriptHelper.alert("Invalid Login: " + e.toString()); 
90. } 

Listing 2.
 
<HTML> 
<HEAD> 
<SCRIPT> 
<!-- 
function com_sssw_AgpPage() 
{ 
} 
var Page=new com_sssw_AgpPage(); 
function com_sssw_submit(name){document.forms[0].elements['AgEvtSrc'].value=name;
document.forms[0].submit();
}Page.submit=com_sssw_submit; 
function com_sssw_onBodyLoad(){ 
Page.FieldLogin=document.forms[0].elements["S5_"]; 
Page.FieldPassword=document.forms[0].elements["S7_"]; 
Page.ButtonLogin=document.forms[0].elements["S9_"]; 
} 
//--> 
</SCRIPT> 

<TITLE>Pathways, Inc.</TITLE> 
</HEAD> 
<BODY onload="com_sssw_onBodyLoad();" BGCOLOR="#FFFFFF">
<FORM METHOD="POST" NAME="AG">
<INPUT TYPE=HIDDEN NAME="AgEvtSrc" VALUE="">
<INPUT TYPE=HIDDEN NAME="AgStateCode" VALUE="1"> 
<P> 
<P><TABLE BORDER=0 BORDERCOLOR="#808080" 
CELLPADDING=0 CELLSPACING=1 WIDTH=160 HEIGHT=0> 
<TR> 
<TD VALIGN=TOP WIDTH=80> 
<P> 
</TD> 
<TD VALIGN=TOP WIDTH=80> 
<P><IMG SRC="../Objectstore/Images/PathwayLogo.gif" WIDTH=332 HEIGHT=53 BORDER=0> 
</TD> 
</TR> 
<TR> 
<TD VALIGN=TOP WIDTH=80> 
<P> 
</TD> 
<TD VALIGN=TOP BGCOLOR="#EDF1C8" WIDTH=80> 
<P> 
<P><BR> 
<P><TABLE BORDER=1 BORDERCOLOR="#808080" 
CELLPADDING=0 CELLSPACING=1 WIDTH=160 HEIGHT=0> 
<TR> 
<TD VALIGN=TOP BGCOLOR="#69738C" WIDTH=80> 
<P><FONT SIZE=2 COLOR="#FFFFFF" FACE="Helvetica">
<SPAN STYLE="font-size:12;">Login 
</SPAN></FONT> 
</TD> 
<TD VALIGN=TOP WIDTH=80> 
<P><INPUT NAME="S5_" TYPE="TEXT" SIZE="20"> 
</TD> 
</TR> 
<TR> 
<TD VALIGN=TOP BGCOLOR="#69738C" WIDTH=80> 
<P><FONT SIZE=2 COLOR="#FFFFFF" FACE="Helvetica"><SPAN STYLE="font-size:12;">Password 
</SPAN></FONT> 
</TD> 
<TD VALIGN=TOP WIDTH=80> 
<P><INPUT NAME="S7_" TYPE="Password" SIZE="20"> 
</TD> 
</TR> 
</TABLE> 
<P> 
</TD> 
</TR> 
<TR> 
<TD VALIGN=TOP WIDTH=80> 
<P> 
</TD> 
<TD VALIGN=TOP WIDTH=80> 
<P ALIGN=LEFT><INPUT VALUE="Login" NAME="S9_" TYPE="SUBMIT"> 
</TD> 
</TR> 
</TABLE> 
</BODY> 
</HTML> 

Listing 3.
 
1. String sClient = "" ; 
2. String sParm = "" ; 
3.  
4. sClient = (String) getSessionValue("ClientKey");  
5. sParm = "CLIENT_KEY=" + sClient; 
6. agScriptHelper.setFrameLocation("CaseManagement.html", "content", sParm, null); 

Listing 4.
 
1. try  
2. { 
3.  String url = "jdbc:sssw:oracle:sid"; 
4. String sSPCommand = ""; 
5.  String sReturn = ""; 
6. boolean bReturn = false; 
7. Integer iClient = new Integer(sClientKey); 
8. Integer iUser = new Integer(sUserKey); 
9.  
10. int intClient = 0; 
11. int intUser = 0; 
12.  
13. intClient = iClient.intValue(); 
14. intUser = iUser.intValue(); 
15. 
16. sSPCommand = "{call pc_income_set_caltotal_sp(?,?)}" ; 
17. System.out.println(sSPCommand); 
18.  
19. Connection con = DriverManager.getConnection( url, "userid", "password"); 
20. 
21. java.sql.CallableStatement stmt = con.prepareCall(sSPCommand); 
22. 
23. stmt.setLong(1, intClient); 
24. stmt.setInt(2, intUser); 
25. stmt.executeUpdate(); 
26.  
27. con.close(); 
28. 
29. } 
30. catch (Exception ex)  
31. { 
32. System.out.println(ex.toString()); 
33. ex.printStackTrace(); 
34. return; 
35. }
 

 

 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.