Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Integer Variable

Status
Not open for further replies.

timmbo

Programmer
Joined
Feb 22, 2001
Messages
167
Location
US
Hi All,

This is a simple question for you Java Gurus out there. My bean needs to return an integer. The error msg I get "Integer can't be resolved or is not a type". How do I set favNbr to return an integer?

TIA,
Tim

Code:
public Integer getFavNumber(String _companyID, String _operatorID) throws ISCException {
		if(SysLog.eventEnabled(7))
			SysLog.logSimpleEvent(7, "OAEPDSP", "Entering SessConnectEJBBean getFavNumber()");

		Connection conn = DBConnFactory.getDBConn();
		Integer favNbr;
		PreparedStatement prepStmt = null;
		ResultSet resSet = null;
		StringBuffer query = new StringBuffer();
		
		favNbr = new integer[0];
		
		try {
			query.append("SELECT MAX(favNum) AS favNum ");
			query.append("FROM custom_report ");
			query.append("WHERE companyID = '" + _companyID + "' ");
			query.append("AND operatorID = '" + _operatorID + "' ");
			
			prepStmt = conn.prepareStatement(query.toString());
			
			//dealing with Oracle bug...
			for (int i = 0;; i++) {
				try {
					//Running query...
					resSet = prepStmt.executeQuery();
				} catch (SQLException SQLE) {
					//8177: ERROR caused by Oracle's optimistic concurrency.  Need to re-execute...
					if (SQLE.getErrorCode() == 8177) {
					} else {
						throw SQLE;
					}
				}
				break;
			}                        
             
			//Reading Resultset...
			while(resSet.next()) {
				//FavNum
				favNbr = new Integer(resSet.getInt("favNum"));
			}			
			
		}catch(Exception e) {
			if(e instanceof ISCException)
				throw (ISCException)e;
			StringPrintStream sps=new StringPrintStream(new StringStream());
			e.printStackTrace(sps);
			SysLog.logSimpleEvent(1, "OAXPDSP", getClass().getName() + ".getFavNumber(): ");
			throw new ISCException("OAXPDSP");                       
        } finally {
			try {
				if (prepStmt != null) {
					prepStmt.close();
				}
				if (conn != null) {
					conn.close();
				}
			} catch (Exception e) {
				SysLog.logSimpleEvent(1, "OAXPDSP", "Exception in getFavNumber() finally.");
			}
		}
 
 		return favNbr;
	}
 
What is this doing :
Code:
favNbr = new integer[0];
Do you mean ("round" braces ()instead of "square" braces []:
Code:
favNbr = new Integer(0);
 
Thanks for the quick reply Hologram. I get the same error when I use round braces. favNbr = new Integer(0);

 
I got it.

Integer favNbr = new Integer(0);

Thanks again for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top