我正在使用带有GlassFish 4.1的NetBeans 8.0.2 IDE。
我有一个JSF Web应用程序AddressBook(来自Deitel和Deitel Java How to Program 9th Edition,Section 30.2),它有一个访问数据库的Java Bean" addressbook"使用以下代码:
// allow the server to inject the DataSource
@Resource( name="jdbc/addressbook" )
DataSource dataSource;
我在Glassfish资源JDBC连接池下创建并ping了AddressBookPool,在Glassfish资源JDBC JDBC资源(NetBeans中的服务选项卡)下创建了jdbc / addressbook。
在“服务”选项卡中,我右键单击数据库下的Java DB,并创建了一个新数据库" addressbook"用户名/密码APP / APP并成功连接数据库jdbc:derby:// localhost:1527 / addressbook [APP on APP]
我选择了jdbc:derby:// localhost:1527 / addressbook连接后运行了一个查询文件,以填充地址簿数据库并查看ADDRESSES表中的数据。
我将Java DB驱动程序库添加到AddressBook项目中,当我运行它时,表格/视图' ADDRESSES'不存在"已在网络浏览器中显示。
由于某种原因,AddressBook Web应用程序没有看到地址簿数据库ADDRESSES表,我可以在“服务”选项卡中查看该表。我需要帮助来弄清楚为什么会这样。以下是浏览器中显示的堆栈跟踪的一部分:
java.sql.SQLSyntaxErrorException:Table / View' ADDRESSES'不存在。 at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(未知来源) at org.apache.derby.client.am.SqlException.getSQLException(未知来源) 在org.apache.derby.client.am.Connection.prepareStatement(未知来源) at com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:586) at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:255) at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:52) at com.sun.gjc.spi.ManagedConnectionImpl.prepareCachedStatement(ManagedConnectionImpl.java:992) at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareStatement(ConnectionWrapper40.java:173) at addressbook.AddressBean.getAddresses(AddressBean.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 在javax.el.BeanELResolver.getValue(BeanELResolver.java:363) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) 在com.sun.el.parser.AstValue.getValue(AstValue.java:140) 在com.sun.el.parser.AstValue.getValue(AstValue.java:204) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) 在javax.faces.component.UIData.getValue(UIData.java:732) 在javax.faces.component.UIData.getDataModel(UIData.java:1822) 在javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484) 在javax.faces.component.UIData.setRowIndex(UIData.java:473) at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:81) 在javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864) 在javax.faces.component.UIData.encodeBegin(UIData.java:1133) 在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854) 在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) 在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) 在com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) 在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 在com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) 在javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) 在org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 在org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 在com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 在org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper $ HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) 在org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) 在org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) 在org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) 在org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) 在org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 在org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) 在org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStrategy.java:56) 在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:565) 在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:545) 在java.lang.Thread.run(Thread.java:745) 引起:org.apache.derby.client.am.SqlException:表/视图' ADDRESSES'不存在。 在org.apache.derby.client.am.Statement.completeSqlca(未知来源) 在org.apache.derby.client.net.NetStatementReply.parsePrepareError(未知来源) 在org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(未知来源) 在org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(未知来源) 在org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(未知来源) 在org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(未知来源) 在org.apache.derby.client.am.Statement.readPrepareDescribeOutput(未知来源) at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source) at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source) 在org.apache.derby.client.am.PreparedStatement.prepare(未知来源) 在org.apache.derby.client.am.Connection.prepareStatementX(未知来源) ......还有64个