derby查询出现表不存在错误

发布于 2021-11-28 18:21:44 字数 14922 浏览 778 评论 2

这两天在Eclipse下用maven搭建了web工程,容器用的是tomcat8.0,使用的是derby(glassfish)框架,数据库是用的内嵌的derby,在网页端想获取derby中相关数据时,控制台报出错误,错误信息提示是:对应的表不存在,获取的信息是通过其它类中的函数查询得到,只要是在网页端的查询就提示表不存在的错误,但在其它测试的类中却可以正常查询?是在是搞不明白,现在是小白一个,这些技术都在学习中,有遇到同样问题的同学帮忙解答下,万分感激!

错误信息如下:

一月 21, 2016 3:07:39 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:UpdateToolsServer' did not find a matching property.
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/8.0.30
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Dec 1 2015 22:30:46 UTC
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         8.0.30.0
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 10
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            10.0
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             C:Program FilesJavajdk1.8.0_60jre
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.8.0_60-b27
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         D:java工作文件件.metadata.pluginsorg.eclipse.wst.server.coretmp21
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         C:apache-tomcat-8.0.30
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:java工作文件件.metadata.pluginsorg.eclipse.wst.server.coretmp21
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=C:apache-tomcat-8.0.30
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:java工作文件件.metadata.pluginsorg.eclipse.wst.server.coretmp21wtpwebapps
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=C:apache-tomcat-8.0.30endorsed
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
一月 21, 2016 3:07:39 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:Program FilesJavajdk1.8.0_60bin;C:WINDOWSSunJavabin;C:WINDOWSsystem32;C:WINDOWS;C:/Program Files (x86)/Java/jre7/bin/client;C:/Program Files (x86)/Java/jre7/bin;C:/Program Files (x86)/Java/jre7/lib/i386;D:oracle11gexpresseditionapporacleproduct11.2.0serverbin;C:ProgramDataOracleJavajavapath;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesIntelIntel(R) Management Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program FilesJavajdk1.8.0_60bin;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:Program Filesnodejs;C:Program FilesTortoiseSVNbin;D:db-derby-10.12.1.1-binbin; D:oracle11gexpressedition;D:oracle11gexpresseditionapporacleproduct11.2.0serverbin;;C:ProgramDataOracleJavajavapath;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesIntelIntel(R) Management Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program FilesJavajdk1.8.0_60bin;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0 ;C:UsersweilichengAppDataRoamingnpm;D:eclipse;;.
一月 21, 2016 3:07:39 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
一月 21, 2016 3:07:39 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
一月 21, 2016 3:07:39 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
一月 21, 2016 3:07:39 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
一月 21, 2016 3:07:39 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1309 ms
一月 21, 2016 3:07:39 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
一月 21, 2016 3:07:39 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.0.30
一月 21, 2016 3:07:40 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [115] milliseconds.
一月 21, 2016 3:07:42 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
一月 21, 2016 3:07:44 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-nio-8080"]
一月 21, 2016 3:07:44 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-nio-8009"]
一月 21, 2016 3:07:44 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 4398 ms
start
false
java.sql.SQLSyntaxErrorException: Table/View 'UT_USER' does not exist.
	at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(Unknown Source)
	at dao.ReadAllUser.UserInfo(ReadAllUser.java:84)
	at resources.UserResources.getUserInfo(UserResources.java:125)
	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.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
	at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
	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: ERROR 42X05: Table/View 'UT_USER' does not exist.
	at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
	at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
	at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown Source)
	at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown Source)
	at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
	at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown Source)
	at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown Source)
	at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
	at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source)
	at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
	at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
	at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
	... 51 more

使用的查询数据库的函数

@SuppressWarnings("rawtypes")
	public static List<Map> UserInfo()
	{
		List<Map> userinfo = new ArrayList<Map>();
		/*HashMap<String,String> temp = new HashMap<String,String>();
		temp.put("用户名","nihao");
		temp.put("角色", "juese");
		temp.put("姓名", "xingming");
		userinfo.add(temp);*/
		
		try{
			System.out.println("start");
			Connection conn = ConnectDB.connectDB();
			System.out.println(conn.isClosed());
			Statement st = conn.createStatement();
			ResultSet rs = st.executeQuery("select * from ut_user");//查询所有用户
			while(rs.next())
			{
				HashMap<String,String> temp = new HashMap<String,String>();
				temp.put("用户名", rs.getString(2));
				temp.put("角色", rs.getString(4));
				temp.put("姓名", rs.getString(5));
				userinfo.add(temp);
			}
			
			rs.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		return userinfo;
	}



jersey资源函数

@SuppressWarnings("rawtypes")
		@GET    
	    @Path("/getUserInfo")    
	    @Produces(MediaType.APPLICATION_JSON)    
	    public List<Map> getUserInfo() {    
	    List<Map> userinfo = ReadAllUser.UserInfo();
	     return userinfo;    
	    }

html中的js函数



<script>
		//直接访问url的安全性问题?没有启动服务器的客户端怎么访问到这个资源
        $(function(){
            $("#btn").click(function(){
                $.getJSON("http://localhost:8080/UpdateToolsServer/rest/users/getUserInfo",function(data){
                    var $tab = $("#tab");
                    var strHtml="";//存储数据的变量
                    /* $jsontip.empty();//清空内容 */
                    $.each(data,function(infoIndex,info){
                        strHtml +="<tr>" + "<td>" + info["用户名"] + "</td>";
                        strHtml +="<td>" + info["角色"] + "</td>";
                        strHtml +="<td>" + info["姓名"] + "</td></tr>";
                        /* strHtml += "<input type=" + ""submit" + """ + ">"; */
                    });
                    $tab.append(strHtml);//显示处理后的数据
                });
            });
        }); 

    </script>





如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感情旳空白 2021-11-30 08:44:32

得看一下连的是不是一个数据库文件

绝影如岚 2021-11-28 21:52:47

找到了错误的原因:在其它类中调用读取数据库函数的时候,使用的是之前已经创建好的数据库,所以查询数据库中相关信息的时候就不会出现错误,但是在发布到tomcat之后,程序会默认在Eclipse的根目录下创建创建同名的数据库,注意新创建的数据库是不包含之前数据已有的信息的,解决办法是在创建数据库连接时,制定数据库的路径,或者将数据库的连接的路径写到配置文件中。

究其根本原因是自己经验太少,水平太次了!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文