begin process at 2012 02 14 07:00:52
  Trouver un code source :
 
dans
 
Accueil > Forum > 

JAVA / J2EE / J2ME

 > 

Réseau & internet

 > 

JavaServerPage (JSP)

 > 

probleme de requete sql


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

probleme de requete sql

lundi 17 mars 2008 à 10:49:12 | probleme de requete sql

luffyst


bonjour a tous,
g besoin de vos connaissances car je débute dans la programmation de java (STRUTS+AJAX+JPA+SPriNG)
mon projet est donc de réaliser une application sur de l'intranet ou net de mon entreprise d'ou l'uttilisation du code HTML dans une page JSP.
je vous met tout mon code et le code erreur aprés compilation
au fait je travail sur éclipse.

Bean : lot
package com.st.mcc.wam.bean;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**

@Entity(name ="Lot")
@Table(name = "LOT")
@NamedQueries(
  @NamedQuery(name = "getAllLots", query="select object(l) from Lot l")
)
public class Lot implements Serializable
{
 /**
  *
  */
 private static final long serialVersionUID = 1L;
 @Id
    @Column(name = "LOTID")
 private String lotId = null;
 private String lattice_code = null;
 private int quantity = 0;
 private String priority = null;
 private String status_lot = null;
 private String hold  = null;
 private String override  = null;
 private int date_debut  = 0;
 private int date_fin = 0;
 private String jalon = null;
 private String technology = null;
 
 /**
  * @return the lattice_code
  */
 public String getLattice_code() {
  return lattice_code;
 }
 /**
  * @param lattice_code the lattice_code to set
  */
 public void setLattice_code(String lattice_code) {
  this.lattice_code = lattice_code;
 }
 /**
  * @return the quantity
  */
 public int getQuantity() {
  return quantity;
 }
 /**
  * @param quantity the quantity to set
  */
 public void setQuantity(int quantity) {
  this.quantity = quantity;
 }
 /**
  * @return the route
  */
 /**
  * @return the priority
  */
 public String getPriority() {
  return priority;
 }
 /**
  * @param priority the priority to set
  */
 public void setPriority(String priority) {
  this.priority = priority;
 }
 /**
  * @return the status_lot
  */
 public String getStatus_lot() {
  return status_lot;
 }
 /**
  * @param status_lot the status_lot to set
  */
 public void setStatus_lot(String status_lot) {
  this.status_lot = status_lot;
 }
 /**
  * @return the hold
  */
 public String getHold() {
  return hold;
 }
 /**
  * @param hold the hold to set
  */
 public void setHold(String hold) {
  this.hold = hold;
 }
 /**
  * @return the override
  */
 public String getOverride() {
  return override;
 }
 /**
  * @param override the override to set
  */
 public void setOverride(String override) {
  this.override = override;
 }
 /**
  * @return the date_debut
  */
 public int getDate_debut() {
  return date_debut;
 }
 /**
  * @param date_debut the date_debut to set
  */
 public void setDate_debut(int date_debut) {
  this.date_debut = date_debut;
 }
 /**
  * @return the date_fin
  */
 public int getDate_fin() {
  return date_fin;
 }
 /**
  * @param date_fin the date_fin to set
  */
 public void setDate_fin(int date_fin) {
  this.date_fin = date_fin;
 }
 /**
  * @return the lotId
  */
 public String getLotId() {
  return lotId;
 }
 /**
  * @param lotId the lotId to set
  */
 public void setLotId(String lotId) {
  this.lotId = lotId;
 }
 /**
  * @return the jalon
  */
 public String getJalon() {
  return jalon;
 }
 /**
  * @param jalon the jalon to set
  */
 public void setJalon(String jalon) {
  this.jalon = jalon;
 }
 /**
  * @return the technology
  */
 public String getTechnology() {
  return technology;
 }
 /**
  * @param technology the technology to set
  */
 public void setTechnology(String technology) {
  this.technology = technology;
 }
 
}

Ensuite avec ce bean j'implémente un form +action+factory ou(DAO) +interface


'lotinfoform' : formulaire:

import

java.util.List;

import

org.apache.struts.action.ActionForm;

import

com.st.mcc.wam.bean.Lot;

publicclass LotInfoForm extends ActionForm {

/**

*

*/

privatestaticfinallongserialVersionUID = 1L;

protected String lotId = null;

protected List<Lot> lotList = null;

/**

*@returnthelot

*/

public String getLotId() {

returnlotId;

}

/**

*@paramlotthelottoset

*/

publicvoid setLotId(String lot) {

this.lotId = lot;

}

/**

*@returnthelotList

*/

public List<Lot> getLotList()

{

returnlotList;

}

/**

*@paramlotListthelotListtoset

*/

publicvoid setLotList(List<Lot> lotList) {

this.lotList = lotList;

}

}

'lotinfoAction' : action:

package

com.st.mcc.wam.action;

import

java.util.List;

import

javax.servlet.http.HttpServletRequest;

import

javax.servlet.http.HttpServletResponse;

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.st.mcc.wam.bean.Lot;

import

com.st.mcc.wam.form.LotInfoForm;

import

com.st.mcc.wam.service.LotFactory;

import

com.st.mcc.wam.service.LotFactoryImpl;

publicclass LotInfoAction extends DispatchAction {

public ActionForward getLotInfo(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response)

throws Exception {

LotFactory lf =

new LotFactoryImpl(); // Factory

List<Lot> lotList = lf.getLots();

//bean job

((LotInfoForm) form).setLotList(lotList);

System.

out.println(" HI HA !");

System.

out.println(" " + ((LotInfoForm) form).getLotId() + " !");

return mapping.findForward("success");

}

}


'lotinfoFactory : FACTORY

package

com.st.mcc.wam.service;

import

java.util.List;

import

com.st.mcc.wam.bean.Lot;

/* create an interface CRUD(Create Read Update Delete) */

public

interface LotFactory

{

public Lot createLot(Lot lot); /* create class Lot (Type attribute) */

public Lot getLot(String lotId); /* String = return a character string LotId */

publicvoid updateLot(Lot lot); /* return nothing because its update a Lot */

publicvoid deleteLot(Lot lot); /*return nothing because its delete a Lot */

public List<Lot> getLots(); /* return a list of lot */

}


'lotinfoFactoryImpl' : action:

package com.st.mcc.wam.service;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.transaction.annotation.Transactional;

import com.st.mcc.wam.bean.Lot;


* This class is a Factory Method to creation of a list lot

*/

/** Pour ce design pattern il faudra indiquer :
*Préciser le nom de la classe.
*Préciser le type d'objet qui seront gérés par la Factory.
*Indiquer si vous désirez que cette factory deviennent aussi un manager,
* c.a.d qu'il est possible de lui confier des objets instanciés à l'extérieur
* de la classe.
*/


/* create a class LotFactoryImpl to implement interface LotFactory  */

public class LotFactoryImpl implements LotFactory
{
 
 /** Logger. */
 private static final Log LOG = LogFactory.getLog(LotFactoryImpl.class);

 private JpaTemplate jpaTemplate= null; /* object JpaTemplate(type) jpaTemplate(attribute) */
 private EntityManager entityManager = null;
 //private EntityManagerImpl = null;
 
 public LotFactoryImpl()
 {
  // default constructor
 }
 
 /* (non-Javadoc)
  * @see com.st.mcc.wam.service.CRUDLotfactory#createLot(com.st.mcc.wam.bean.Lot)
  */
 @Transactional /* an annotation  */
 public Lot createLot(Lot lot)  /*Create a Lot */
 {
  LOG.debug("create of lot (begin)");

  LOG.debug("id = " + lot.getLotId());
  
  /* try a LOG with jpaTemplate  */
 try {
   jpaTemplate.persist(lot);/*.persist(lot)= persistence Object(Lot) */
   jpaTemplate.flush(); /* .flush = empty a memory or up to date of memory */
   LOG.debug("create of lot (end)");

   return lot;
 }
  
  /* Failure so catch an exception to runtime */
  catch (RuntimeException e)
 {
  LOG.error("problem !");
   return null;
  }
 }

 /* (non-Javadoc)
  * @see com.st.mcc.wam.service.CRUDLotFactory#deleteLot(com.st.mcc.wam.bean.Lot)
  */
 @Transactional
 public void deleteLot(Lot lot) {
  // TODO Auto-generated method stub
  
 }

 /* (non-Javadoc)
  * @see com.st.mcc.wam.service.CRUDLotFactory#readLot(com.st.mcc.wam.bean.Lot)
  */
 @Transactional
 public Lot getLot(String lotId) {
  LOG.debug("search of lot (begin)");

  LOG.debug("id = " + lotId);
  try {
   Lot lot = jpaTemplate.find(Lot.class, lotId);/* .find serve to find a lot */
   LOG.debug("search of lot (end)");

   return lot;  /*find a lot so return a lot*/
  } catch (RuntimeException e) {
   LOG.error("problem !");
   return null;  /* not find a lot so return null and to start again a search */
  }
 }

 /* (non-Javadoc)
  * @see com.st.mcc.wam.service.CRUDLotFactory#updateLot(com.st.mcc.wam.bean.Lot)
  */
 @Transactional
 public void updateLot(Lot lot)
 {
  // TODO Auto-generated method stub
  
 }

 /*the connection at BDD = EntityManagerFactory */
 
 public void setEntityManagerFactory(EntityManagerFactory emf)
 {
  this.jpaTemplate = new JpaTemplate(emf); 
  this.entityManager = emf.createEntityManager();
 }


 @Transactional
 
 public List<Lot> getLots()
 {

  for(int i=0; i<10; i++)
  { 
   Lot l = new Lot();
   l.setLotId("GXXXXXX_"+ i);
   l.setLattice_code("ET_CONT_VIA");
   l.setQuantity(3);
   l.setJalon("J05");
   l.setTechnology("M10");
   l.setPriority("P12");
   l.setStatus_lot("Wait");
   l.setHold("N");
   l.setOverride("Y");
   int date_begin = 06/02/2008;
   l.setDate_debut(date_begin);
   l.setDate_debut(06/02/2008);
   int date_end = 17/04/2008;
   l.setDate_fin(date_end);
   this.createLot(l);
   LOG.debug("Lot = " + l.getLotId() );
  }
  
  List<Lot> lotList=jpaTemplate.find("SELECT LOTID FROM LOT ");
 
  
  
  jpaTemplate.findByNamedQuery("getAllLots",lotList);
   /** This is the list of object **/
   return lotList;
 }

}

erreur lors de l'ouverture de la page WEB:

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException 	org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286) 	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) 	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:697) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 	org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 

root cause

java.lang.NullPointerException 	com.st.mcc.wam.service.LotFactoryImpl.getLots(LotFactoryImpl.java:149) 	com.st.mcc.wam.action.LotInfoAction.getLotInfo(LotInfoAction.java:33) 	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 	java.lang.reflect.Method.invoke(Method.java:585) 	org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269) 	org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170) 	org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) 	org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) 	org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) 	org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) 	org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) 	org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) 	org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) 	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) 	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:697) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 	org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 




 voila , je vous remercie d'avance


Cette discussion est classée dans : java, public, import, return, lot


Répondre à ce message

Sujets en rapport avec ce message

A l'aide? AbstractTableModel,JTable [ par ilmb ] Bonjour, à tous!Voici mon problème, je veux rentrer des objects dans une AbstracTableModel, pour qui l'affiche à l'écran le seul problème c'est que à pb affichage image compren po :( [ par doudoudidoune ] je commence en java et pr l'instant g fait un pti pgm ki affiche une fenetre ac un menu déroulant et un bouton... super...bref j'aimerai y intégrer un Pb de Collection [ par jesuhsXVII ] J'ai un petit pb, c surement tout bete ... bref Voici le code :package SystemDeFichier;import java.util.*;import java.io.File;public class BoutonNavig Tentative d'editeur de map [ par Bouki ] Voila je tente de faire un editeur de map, mon pb c'est que l'image ne s'affiche pas et qu'il n'y a aucune réaction au clic (j'ai essayé des println p Impression du contenu d'un JTextArea sur plusieurs pages [ par criche ] Voici un programme qui me permet d'imprimer le contenu d'un JtextArea.Il est composé du programme essaiJtextArea.java, qui appelle la classe JTextArea probleme avec un applet chat [ par funbidule ] J'ai un probleme avec ce programme il crès bien la fenetre mais n essaie pas de se connecter au serveurQuelqu'un saurait il m aider?package chat;impor applet, swing class et constructeur. [ par nonoz ] bonjour,j'aurais besoin d'un peu d'aide parce que je comprends pas bien ce qu'il faut que je fasse (enfin si faire un constructeur mais ou et comment listener dnas une applet??? [ par nonoz ] Bon je mets ma question ici car je sais pas trop ou la mettre ailleurs... j'essaye d'ajouter un listener sur mes boutons qu'il lorsque l'on clique des newbie question dessiner java [ par anisotrope ] Bonjour a tous.Tout d'abord avant d'exposer mon probleme je voudrais dire que je viens juste de commencer le java donc un peu d'indulgence :=).Voila j Problème rafraichissement image avec Swing [ par ejouvin ] Bonjour.Je suis en train de faire une petite application qui contient une arborescence à gauche et une fenêtre de détail sur la droite.Dans le code su


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,044 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales