The error messages says that stmt/rs already have been declared. This is done in these lines in the beginning of the method //Declare and initialize variables Connection conn = null; Statement stmt = null; ResultSet rs = null;
Change the later lines and remove the "Statement" and "ResultSet" words respectively
and it should compile
Regards Mikael
At 13:20 2003-08-24 -0500, you wrote:
I've been trying to compile my BLB (Business Logic Bean) and have been getting errors during compilation. I haven't a clue as to how I could debug this. Any assistance would be appreciated.
Thanks in advance.
- Mitesh
Error Messages during compilation:
[javac] Compiling 2 source files to C:\jakarta-tomcat-4.1.27\webapps\benchmark\WEB-INF\classes
[javac] C:\jakarta-tomcat-4.1.27\webapps\benchmark\WEB-INF\src\net\reumann\OrgIdService.java:56: stmt is already defined in execute(net.reumann.DataHash)
[javac] Statement stmt = conn.createStatement();
[javac] ^
[javac] C:\jakarta-tomcat-4.1.27\webapps\benchmark\WEB-INF\src\net\reumann\OrgIdService.java:57: rs is already defined in execute(net.reumann.DataHash)
[javac] ResultSet rs = stmt.executeQuery("SELECT FACIL_ID, FACIL_NAME, FACIL_NAME_SHORT, ORG_ID FROM FACILITY WHERE FACIL_ID = '" + facilId + "'");
[javac] ^
[javac] 2 errors
Here is the code from my BLB:
package net.reumann;
import java.io.*; import java.util.ArrayList; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import javax.sql.*; import net.reumann.*; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.log4j.*; import org.apache.commons.beanutils.BeanUtils;
public class OrgIdService implements Serializable {
//Declare and initialize variables Connection conn = null; Statement stmt = null; ResultSet rs = null; ArrayList facilList = new ArrayList();
//The execute() method of OrgIdService is called by OrgIdAction to execute a query against the SS Test DB
public ArrayList execute(DataHash beanHash) {
//Get mode from DataHash int mode = beanHash.getMode();
try{ switch (mode) { case 0:
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@sources:1521:TEST","Test1234","Test1234");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT DISTINCT FACIL_ID FROM FACILITY");
//Read ResultSet into instance of FacilBean and add to facilList Array object
while (rs.next()) {
FacilBean facil = new FacilBean();
facil.setFacilId(rs.getString("FACIL_ID")); facilList.add(facil); }
//Close ResultSet and Connection objects
rs.close();
conn.close();
case 1:
//Extract the facilId from the DataHash to query the FACILITY table
String facilId = (String) beanHash.get("FacilId");
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@sources:1521:TEST","Test1234","Test1234");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT FACIL_ID, FACIL_NAME, FACIL_NAME_SHORT, ORG_ID FROM FACILITY WHERE FACIL_ID = '" + facilId + "'");
//Read ResultSet into instance of FacilBean and add to facilList Array object
while (rs.next()) {
FacilBean facil = new FacilBean();
facil.setFacilId(rs.getString("FACIL_ID"));
facil.setFacilName(rs.getString("FACIL_NAME"));
facil.setFacilName(rs.getString("FACIL_NAME_SHORT"));
facil.setOrgId(rs.getString("ORG_ID")); facilList.add(facil); }
//Close ResultSet and Connection objects
rs.close();
conn.close();
default:
return null;
}//end Switch
}//end try
catch (Exception e) {
return null;
e.printStackTrace();
}//end catch
//Return facilList Array Object to OrgIdAction return facilList; }//end Execute () method }//end class
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

