RE: Java Question

2003-08-26 Thread Kapadia Mitesh-C23457
Sorry folks -- Please disregard my previous message w/subject --  'Java
Question'

-Original Message-
From: Kapadia Mitesh-C23457 [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 24, 2003 1:33 PM
To: [EMAIL PROTECTED]
Subject: Java Question
Importance: High


> 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\Org
> IdSe
> rvice.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\OrgIdSe
> rvice.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","Tes
> t123
> 4","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","Tes
> t123
> 4","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
>   

RE: Java Question

2003-08-26 Thread Steve Raeburn
This question was asked and *answered* yesterday.

http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]
he.org&msgNo=86724

Is there any reason you are repeating the it?

Steve

> -Original Message-
> From: Kapadia Mitesh-C23457 [mailto:[EMAIL PROTECTED]
> Sent: August 24, 2003 11:21 AM
> To: [EMAIL PROTECTED]
> Subject: Java Question
>
>
> 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
>
...



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Java Question

2003-08-25 Thread Syed, Nazeer
Since you have already Defined the conn and stmt you no need to defined
again .

 

 

 

 

public class OrgIdService implements Serializable {

 

  //Declare and initialize variables

  Connection conn = null;

  Statement stmt = null;

  ResultSet rs = null;

  ArrayList facilList = new ArrayList();

 

 

Just remove  Statement and ResultSet  from line 56 and 57

Compile again it will work fine.

 

 

Eg :

stmt = conn.createStatement();

rs = stmt.executeQuery("SELECT

 

 

Thanks

Nazeer

 

 

-Original Message-
From: Kapadia Mitesh-C23457 [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 24, 2003 2:21 PM
To: [EMAIL PROTECTED]
Subject: Java Question

 

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\OrgId
Service.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\OrgId
Service.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","Test1
234","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","Test1
234","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 

RE: Java Question

2003-08-25 Thread Paananen, Tero
> [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\reu
> mann\OrgIdService.java:56: stmt is already defined in 
> execute(net.reumann.DataHash)
> [javac] Statement 
> stmt = conn.createStatement();

You are kidding, right?

-TPP

-
This email may contain confidential and privileged material for the sole use of the 
intended recipient(s). Any review, use, retention, distribution or disclosure by 
others is strictly prohibited. If you are not the intended recipient (or authorized to 
receive for the recipient), please contact the sender by reply email and delete all 
copies of this message.  Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive emails on the 
basis that we are not liable for any such corruption, interception, tampering, 
amendment or viruses or any consequence thereof.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Java Question

2003-08-25 Thread Mikael Eriksson - Swedish Connection
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();
  

RE: Java Question

2003-08-24 Thread Mike Whittaker

>
>> 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.
>>
>

ResultSet rs =
stmt.executeQuery("SELECT FACIL_ID, FACIL_NAME, FACIL_NAME_SHORT, ORG_ID
FROM FACILITY WHERE FACIL_ID = '" + facilId + "'");

Change that line to:

rs =
stmt.executeQuery("SELECT FACIL_ID, FACIL_NAME, FACIL_NAME_SHORT, ORG_ID
FROM FACILITY WHERE FACIL_ID = '" + facilId + "'");

You can not redeclare a variable in the same scope.

The way you were trying to do it was have two variables called rs in the
same scope, the ammendment, simply replaces one resultset with another, for
the object reference - rs.

--
Mike W


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Java Question

2003-08-24 Thread Oliver Reflé
Hi,
you are declaring your stmt variable twice. This is not allowed.
Just use name stmt.

Check below to find the error

Olli
> > 
> > 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","Test123
> > 4","Test1234");

//here you declare stmt
> > 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","Test123
> > 4","Test1234");

here again
> > 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
> 

-- 
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Java Question

2003-08-24 Thread Mark Lowe
Read the messages its telling you what's going on..

You've got 2 errors..

1. stmt is already defined
2. that rs is already defined
I don't know how much simpler this could be..

On Sunday, August 24, 2003, at 07:32 PM, Kapadia Mitesh-C23457 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\OrgIdSe
rvice.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\OrgIdSe
rvice.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","Tes 
t123
4","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","Tes 
t123
4","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
r

Re: Java Question

2003-08-24 Thread Dan Tran
Try to import only what you need, not the whole package. It can help you to
trouble shoot this problem

-D
- Original Message - 
From: "Kapadia Mitesh-C23457" <[EMAIL PROTECTED]>
Newsgroups: Struts
Sent: Sunday, August 24, 2003 11:32 AM
Subject: Java Question


> > 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\OrgIdSe
> > rvice.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\OrgIdSe
> > rvice.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","Test123
> > 4","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","Test123
> > 4","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]