permaculture playing cards*
The moose likes JDBC and the fly likes IllegalStateException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "IllegalStateException" Watch "IllegalStateException" New topic
Author

IllegalStateException

shumani edzani
Greenhorn

Joined: Oct 03, 2008
Posts: 9
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

Joined: Mar 24, 2008
Posts: 3855

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
It means the mentioned column name is no valid,
can you post the full stack trace so that we can have a better understanding.


SCJP 1.5
shumani edzani
Greenhorn

Joined: Oct 03, 2008
Posts: 9
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

Joined: Aug 03, 2008
Posts: 9313
    
  17

This is SCJP section and Database Connectivity is not a part of SCJP. So please post this problem in Beginner or Intermediate section....


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14352
    
  22

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IllegalStateException