Como mostrar en un datatable de primefaces registros de una tabla relacionada
Buenas noches ante su prestigiosa comunidad
tengo un inconveniente al momento de hacer el registro no me muestra dos campos que se muestran en la imagen
le deje el codigo web
muchas gracias
Adjunto | Tamaño |
---|---|
farmacia2.jpg | 103.63 KB |
- Inicie sesión o regístrese para enviar comentarios
Casi solucionado
cuando hice mi consuta con
PreparedStatement st=this.getCn().prepareCall("select M.codmedicamento,M.nomMedicamento,M.concentracion,F.descripcion,L.nomLaboratorio,M.precio,M.fechaCaducidad,M.stock,M.lote\n" +
" from medicamento M ,laboratorio L,formafarmaceutica F" +
"inner join on M.codLaboratorio =L.codLaboratorio "
+ "innner join on "
+ "M.codFormafamaceutica=F.codFormafamaceutica");
y al momento de levantar el aplicativo web ,la base de datos esta en MYSQ el mensaje del log me sale el siguiente error
dic 01, 2015 10:44:29 AM javax.faces.component.UIViewRoot$ViewMap put
ADVERTENCIA: Definiendo valor de atributo no serializable en ViewMap: (clave: medicamentosBean, clase de valor: com.ventura.bean.MedicamentosBean)
dic 01, 2015 10:44:36 AM javax.faces.component.UIViewRoot$ViewMap put
ADVERTENCIA: Definiendo valor de atributo no serializable en ViewMap: (clave: formaFarmaceuticaBean, clase de valor: com.ventura.bean.FormaFarmaceuticaBean)
dic 01, 2015 10:44:36 AM javax.faces.component.UIViewRoot$ViewMap put
ADVERTENCIA: Definiendo valor de atributo no serializable en ViewMap: (clave: laboratorioBean, clase de valor: com.ventura.bean.LaboratorioBean)
dic 01, 2015 10:44:36 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: JSF1073: se ha interceptado javax.el.ELException durante el procesamiento de RENDER_RESPONSE 6 : UIComponent-ClientId=, Mensaje=/medicamentos.xhtml @19,92 listener="#{medicamentosBean.listar('F')}": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on M.codLaboratorio =L.codLaboratorio innner join on M.codFormafamaceutica=F.co' at line 2
dic 01, 2015 10:44:36 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: /medicamentos.xhtml @19,92 listener="#{medicamentosBean.listar('F')}": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on M.codLaboratorio =L.codLaboratorio innner join on M.codFormafamaceutica=F.co' at line 2
javax.el.ELException: /medicamentos.xhtml @19,92 listener="#{medicamentosBean.listar('F')}": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on M.codLaboratorio =L.codLaboratorio innner join on M.codFormafamaceutica=F.co' at line 2
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128)
at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2603)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)
at javax.faces.event.ComponentSystemEvent.processListener(ComponentSystemEvent.java:118)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2187)
at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2135)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:289)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247)
at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:726)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2440)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2429)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on M.codLaboratorio =L.codLaboratorio innner join on M.codFormafamaceutica=F.co' at line 2
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.Util.getInstance(Util.java:382)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2273)
at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:943)
at com.ventura.dao.MedicamentosDao.listar(MedicamentosDao.java:62)
at com.ventura.bean.MedicamentosBean.listar(MedicamentosBean.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
... 34 more
a que se debe este error y como puedo solucionarlo tb hice un procedimiento almacenado es la union de 3 tablas no estoy usando hibernate espero su pronto apoyo muchas gracias.
Casi solucionado
El problema está en la consulta, no estas usando el 'inner join' de forma correcta.
La sintaxis es la siguiente:
SELECT campos FROM tabla1
INNER JOIN tabla2 ON tabla2.id = tabla1.id
INNER JOIN tabla3 ON tabla3.id = tabla2.id1
WHERE condicion
salu2