Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalStateException

 
shumani edzani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to display a report and is unable to display it and gives me the following error and how do i fix the problem

java.sql.SQLException: Unknown column 'appraisal.appraisee' in 'on clause'
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you are missing some column name in your SQL statement or you might have wrong column name in your SQL. Very hard to say without looking at the actual code. Please post your code.
 
Bharadwaj Adepu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means the mentioned column name is no valid,
can you post the full stack trace so that we can have a better understanding.
 
shumani edzani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the code required

/*

* Created on Aug 16, 2004

*

* To change the template for this generated file go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

package com.tsc.tami.web.struts.actions;



import java.rmi.RemoteException;

import java.util.ArrayList;

import java.util.Collection;



import javax.ejb.CreateException;

import javax.ejb.EJBException;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;



import org.apache.log4j.Logger;

import org.apache.struts.action.ActionError;

import org.apache.struts.action.ActionErrors;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import org.apache.struts.actions.DispatchAction;



import com.tsc.util.uuid.UUIDUtility;

import com.tsc.util.uuid.exceptions.UUIDgeneratorException;

import com.tsc.tami.web.struts.forms.DepartmentForm;



import com.tsc.tami.model.dto.DepartmentDTO;

import com.tsc.tami.model.dto.StaticdataDto;

import com.tsc.tami.model.interfaces.HruserMgr;

import com.tsc.tami.model.interfaces.HruserMgrHome;

import com.tsc.tami.model.interfaces.Staticdata;

import com.tsc.tami.model.interfaces.StaticdataMgr;

import com.tsc.tami.model.interfaces.StaticdataMgrHome;

import com.tsc.tami.util.config.AppConstants;

import com.tsc.tami.util.ejb.JNDInames;

import com.tsc.tami.util.ejb.ServiceLocator;

import com.tsc.tami.util.ejb.ServiceLocatorException;

import com.tsc.util.trace.Debug;



/**

* @author Patrick

*

* To change the template for this generated type comment go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

public class DepartmentAction extends DispatchAction {



Logger log = Logger.getLogger(getClass());



public ActionForward getDepartmentById(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {



ActionForward forward = new ActionForward();

HttpSession httpSession = request.getSession();

DepartmentForm departmentform = (DepartmentForm) form;



//initialization of the llocal variables

String parentID = (String) httpSession.getAttribute("parentID");

String id = request.getParameter("id");

httpSession.setAttribute("deptid", id);

forward = mapping.findForward("simpleSqlReport");



if (parentID == null) {



parentID = departmentform.getParentid();



}



// set up the user manager session bean

ServiceLocator serviceLocator = null;

try {

serviceLocator = ServiceLocator.getInstance();

} catch (ServiceLocatorException e) {

String msg = e.getClass().getName() + ", MSG: " + e.getMessage();

throw new EJBException(e);

}



try {



/***Lookup the static data manager***/

StaticdataMgrHome staticDataMgrHome =

(StaticdataMgrHome) ServiceLocator.getEjbHome(

JNDInames.staticdataMgrRemote,

StaticdataMgrHome.class);

StaticdataMgr staticDataMgr = staticDataMgrHome.create();



StaticdataDto staticdatadto =

staticDataMgr.staticdataFindByPrimaryKey(id);

departmentform.setDepartmentname(staticdatadto.getName());

departmentform.setDepartmentid(id);



} catch (Exception e) {

log.debug("Exception " + e.getMessage());

e.printStackTrace();

}



// append the required parameters to the forward URL path

StringBuffer forwardUrlPath = new StringBuffer(forward.getPath());

forwardUrlPath.append(

".do?XMLQueryFile=" + AppConstants.XMLQUERYFILE_CURRENT_DEPARTMENTS);

forwardUrlPath.append("&parentid=" + parentID);



// create a new ActionForward to return because we are

// unable to update the existing one

ActionForward newForward = new ActionForward();

newForward.setPath(forwardUrlPath.toString());



return newForward;

}



public ActionForward addDeparment(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {



ActionForward forward = new ActionForward();

HttpSession httpSession = request.getSession();

DepartmentForm departmentform = (DepartmentForm) form;

StaticdataDto staticdatadto = new StaticdataDto();

UUIDUtility uuid = new UUIDUtility();



ServiceLocator serviceLocator = null;

String parentID = (String) httpSession.getAttribute("parentID");

forward = mapping.findForward("simpleSqlReport");



String departmentId = (String) httpSession.getAttribute("deptid");

String deptname = departmentform.getDepartmentname().trim();



staticdatadto.setName(deptname);

staticdatadto.setParentid(parentID);

staticdatadto.setDescr(deptname);

staticdatadto.setTypeid("DEPARTMENT");



// uuid creates a primary key for the department

String uuId = uuid.getUUID();

staticdatadto.setId("D" + uuId);



/***Lookup the static data manager***/

StaticdataMgrHome staticDataMgrHome =

(StaticdataMgrHome) ServiceLocator.getEjbHome(

JNDInames.staticdataMgrRemote,

StaticdataMgrHome.class);

StaticdataMgr staticDataMgr = staticDataMgrHome.create();

log.debug("id " + departmentId);



StaticdataDto[] find = staticDataMgr.staticdataFindByTypeid("DEPARTMENT");

for (int i = 0; i < find.length; i++) {



if (find[i].getName().equalsIgnoreCase(deptname)) {



ActionErrors errors = new ActionErrors();

ActionError error = new ActionError("error.department.exist");

errors.add(ActionErrors.GLOBAL_ERROR, error);

saveErrors(request, errors);



// append the required parameters to the forward URL path

StringBuffer forwardUrlPath = new StringBuffer(forward.getPath());

forwardUrlPath.append(

".do?XMLQueryFile=" + AppConstants.XMLQUERYFILE_CURRENT_DEPARTMENTS);

forwardUrlPath.append("&parentid=" + parentID);



// create a new ActionForward to return because we are

// unable to update the existing one

ActionForward newForward = new ActionForward();

newForward.setPath(forwardUrlPath.toString());



return newForward;



}

}

StaticdataMgrHome staticdataMgrHome =

(StaticdataMgrHome) ServiceLocator.getEjbHome(

JNDInames.staticdataMgrRemote,

StaticdataMgrHome.class);

StaticdataMgr staticdataMgr = staticdataMgrHome.create();



staticdataMgr.createStaticdata(staticdatadto);

log.debug("staticdataMgrHome " + staticdataMgrHome.toString());



// append the required parameters to the forward URL path

StringBuffer forwardUrlPath = new StringBuffer(forward.getPath());

forwardUrlPath.append(

".do?XMLQueryFile=" + AppConstants.XMLQUERYFILE_CURRENT_DEPARTMENTS);

forwardUrlPath.append("&parentid=" + parentID);



// create a new ActionForward to return because we are

// unable to update the existing one

ActionForward newForward = new ActionForward();

newForward.setPath(forwardUrlPath.toString());



return newForward;



}



public ActionForward updateDeparment(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {



ActionForward forward = new ActionForward();

HttpSession httpSession = request.getSession();

DepartmentForm departmentform = (DepartmentForm) form;

StaticdataDto staticdatadto = new StaticdataDto();



ServiceLocator serviceLocator = null;

String parentID = (String) httpSession.getAttribute("parentID");

forward = mapping.findForward("simpleSqlReport");



String id = (String) httpSession.getAttribute("deptid");

String deptname = departmentform.getDepartmentname();



staticdatadto.setId(departmentform.getDepartmentid());

staticdatadto.setName(departmentform.getDepartmentname());

staticdatadto.setParentid(parentID);

staticdatadto.setDescr(departmentform.getDepartmentname());

staticdatadto.setTypeid("DEPARTMENT");



/***Lookup the static data manager***/

StaticdataMgrHome staticDataMgrHome =

(StaticdataMgrHome) ServiceLocator.getEjbHome(

JNDInames.staticdataMgrRemote,

StaticdataMgrHome.class);

StaticdataMgr staticDataMgr = staticDataMgrHome.create();



//StaticdataDto find = staticDataMgr.staticdataFindByPrimaryKey(id);



StaticdataDto[] find = staticDataMgr.staticdataFindByTypeid("DEPARTMENT");

for (int i = 0; i < find.length; i++) {



if (find[i].getName().equalsIgnoreCase(deptname)) {



ActionErrors errors = new ActionErrors();

ActionError error = new ActionError("error.department.exist");

errors.add(ActionErrors.GLOBAL_ERROR, error);

saveErrors(request, errors);



// append the required parameters to the forward URL path

StringBuffer forwardUrlPath = new StringBuffer(forward.getPath());

forwardUrlPath.append(

".do?XMLQueryFile=" + AppConstants.XMLQUERYFILE_CURRENT_DEPARTMENTS);

forwardUrlPath.append("&parentid=" + parentID);



// create a new ActionForward to return because we are

// unable to update the existing one

ActionForward newForward = new ActionForward();

newForward.setPath(forwardUrlPath.toString());



return newForward;



}

}

StaticdataMgrHome staticdataMgrHome =

(StaticdataMgrHome) ServiceLocator.getEjbHome(

JNDInames.staticdataMgrRemote,

StaticdataMgrHome.class);

StaticdataMgr staticdataMgr = staticdataMgrHome.create();



staticdataMgr.updateStaticdata(staticdatadto);

log.debug("staticdataMgrHome " + staticdataMgrHome.toString());



// append the required parameters to the forward URL path

StringBuffer forwardUrlPath = new StringBuffer(forward.getPath());

forwardUrlPath.append(

".do?XMLQueryFile=" + AppConstants.XMLQUERYFILE_CURRENT_DEPARTMENTS);

forwardUrlPath.append("&parentid=" + parentID);



// create a new ActionForward to return because we are

// unable to update the existing one

ActionForward newForward = new ActionForward();

newForward.setPath(forwardUrlPath.toString());



return newForward;

}



public ActionForward deleteDeparment(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {



ActionForward forward = new ActionForward();

HttpSession httpSession = request.getSession();

DepartmentForm departmentform = (DepartmentForm) form;

StaticdataDto staticdatadto = new StaticdataDto();



ServiceLocator serviceLocator = null;

String parentID = (String) httpSession.getAttribute("parentID");

forward = mapping.findForward("simpleSqlReport");



staticdatadto.setId(departmentform.getDepartmentid());

staticdatadto.setName(departmentform.getDepartmentname());

staticdatadto.setParentid(parentID);



HruserMgrHome hrUserMgrHome =

(HruserMgrHome) ServiceLocator.getEjbHome(

JNDInames.hruserMgrRemote,

HruserMgrHome.class);

HruserMgr hrUserMgr = hrUserMgrHome.create();



log.debug(

"departmentform.getDepartmentname()"

+ departmentform.getDepartmentname());

/**find a collection of users in the department*/

ArrayList users =

hrUserMgr.hrusersFindByDepartment(departmentform.getDepartmentid());

log.debug("users.size()" + users.size());



if (users.size() == 0) {



StaticdataMgrHome staticdataMgrHome =

(StaticdataMgrHome) ServiceLocator.getEjbHome(

JNDInames.staticdataMgrRemote,

StaticdataMgrHome.class);

StaticdataMgr staticdataMgr = staticdataMgrHome.create();



staticdataMgr.removeStaticdata(staticdatadto);

} else {

ActionErrors errors = new ActionErrors();

ActionError error = new ActionError("error.cannot.delete");

errors.add(ActionErrors.GLOBAL_ERROR, error);

saveErrors(request, errors);

}



// append the required parameters to the forward URL path

StringBuffer forwardUrlPath = new StringBuffer(forward.getPath());

forwardUrlPath.append(

".do?XMLQueryFile=" + AppConstants.XMLQUERYFILE_CURRENT_DEPARTMENTS);

forwardUrlPath.append("&parentid=" + parentID);



// create a new ActionForward to return because we are

// unable to update the existing one

ActionForward newForward = new ActionForward();

newForward.setPath(forwardUrlPath.toString());



return newForward;

}

}
 
Ankit Garg
Sheriff
Posts: 9520
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is SCJP section and Database Connectivity is not a part of SCJP. So please post this problem in Beginner or Intermediate section....
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15274
38
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

When you post a question here, please take a moment to choose an appropriate forum.

This question does not have anything to do with the SCJP exam, so it does not belong in the SCJP forum. I will move this topic to a more appropriate forum for you. Click the link at the top of the page to continue.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic