原因不明的Vaadin错误

时间:2015-04-06 14:40:53

标签: java eclipse vaadin

我试图做一个简单的测试,我的Vaadin程序只需连接到MS SQL Server数据库并检索一些数据。没什么大不了的,除了Vaadin想让它成为一个大问题。

我不知道发生了什么,但我现在正处于无论我对VaadinConnManager课程做出什么改变的地方,我都得到确切的相同的错误消息(" 完全相同的行号附近的' LIMIT'"语法不正确),即使该行号什么都没有。就像程序在某个特定版本上卡住一样,并且不会接受我所做的任何其他更改。

我认为它至少部分与我在Eclipse中遇到的奇怪错误有关。这是它的样子:

Very odd error icons

我圈出了两个相关的图标。通常是"红色X" icon表示程序中存在错误,通常位于.java个源文件中。但正如您所看到的,我的任何源文件都没有这样的错误。在“Java资源”中,似乎还有一个惊悚的感叹号。夹。我认为小地球图标只是隐藏了它的上半部分,这就是为什么它看起来像一个红色的沙漏。而不是一个红色感叹号。

Eclipse告诉我这些错误是什么没有帮助。或者,至少,我无法弄明白。不可否认,我仍在学习Eclipse,所以完全有可能我不知道在哪里寻找这些红色标记的解释。

修改

我粘贴了上面屏幕截图中相关的两个.java文件中的代码,以及错误堆栈跟踪。

VaadinsqltestUI.java:

package info.chrismcgee.sky.vaadinsqltest;

import java.sql.SQLException;

import info.chrismcgee.sky.vaadinsqltest.dbutil.ConnectionManager;
import info.chrismcgee.sky.vaadinsqltest.dbutil.VaadinConnManager;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.data.util.sqlcontainer.SQLContainer;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
@Theme("vaadinsqltest")
public class VaadinsqltestUI extends UI {

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = VaadinsqltestUI.class)
    public static class Servlet extends VaadinServlet {
    }

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        Button button = new Button("Click Me");
        button.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
//              try {
//                  ConnectionManager connMan = new ConnectionManager();
                    SQLContainer container = VaadinConnManager.getJobs();
/*              } catch (SQLException | ClassNotFoundException e) {
                    e.printStackTrace();
                }*/
                layout.addComponent(new Label("Thank you for clicking"));
            }
        });
        layout.addComponent(button);
    }

}

VaadinConnManager.java:

package info.chrismcgee.sky.vaadinsqltest.dbutil;

import java.sql.SQLException;
import java.util.logging.Logger;

import com.vaadin.data.util.sqlcontainer.SQLContainer;
import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
import com.vaadin.data.util.sqlcontainer.query.FreeformQuery;
import com.vaadin.data.util.sqlcontainer.query.TableQuery;
import com.vaadin.data.util.sqlcontainer.query.generator.MSSQLGenerator;

public class VaadinConnManager {

    Logger logger = Logger.getLogger(VaadinConnManager.class.getName());

    private static final String USERNAME = "web";
    private static final String PASSWORD = "web";
    private static final String CONN_STRING = "jdbc:sqlserver://192.168.0.248;databaseName=job_orders_2014";

    public VaadinConnManager() {
        }

    public static SQLContainer getJobs() {

        JDBCConnectionPool pool = null;
//      SQLContainer container;

        try {
            pool = new SimpleJDBCConnectionPool("com.microsoft.sqlserver.jdbc.SQLServerDriver", CONN_STRING, USERNAME, PASSWORD, 2, 5);
            System.out.println("Connected!");
        } catch (SQLException e) {
            System.err.println(e);
        }
/*  
//      MSSQLGenerator generator = new MSSQLGenerator();
//      TableQuery tq = new TableQuery("Job", pool, generator);
//      tq.setVersionColumn("proof_spec_date");

//      FreeformQuery query = new FreeformQuery("SELECT * FROM Job AS j JOIN OrderDetail AS o ON j.job_id = o.order_id", pool, "job_id");
        FreeformQuery query = new FreeformQuery("SELECT * FROM Job", pool, "job_id");

        try {
            container = new SQLContainer(query);
            return container;
        } catch (SQLException e) {
            System.err.println(e);
        }*/

        return null;
    }

}

堆栈跟踪:

Apr 08, 2015 3:14:01 PM org.atmosphere.cpr.AtmosphereFramework info
INFO: Atmosphere is using async support: org.atmosphere.container.JSR356AsyncSupport running under container: Apache Tomcat/8.0.18 using javax.servlet/3.0 and jsr356/WebSocket API
Apr 08, 2015 3:14:01 PM org.atmosphere.cpr.AtmosphereFramework info
INFO: Atmosphere Framework 2.2.4.vaadin5 started.
Apr 08, 2015 3:14:01 PM org.atmosphere.cpr.AtmosphereFramework interceptor
INFO: Installed AtmosphereInterceptor  Track Message Size Interceptor using | with priority BEFORE_DEFAULT 
Connected!
Apr 08, 2015 3:14:06 PM com.vaadin.data.util.sqlcontainer.SQLContainer getPropertyIds
WARNING: Failed to fetch property ids, rolling back
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'LIMIT'.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:285)
    at com.vaadin.data.util.sqlcontainer.query.TableQuery.executeQuery(TableQuery.java:529)
    at com.vaadin.data.util.sqlcontainer.query.TableQuery.getResults(TableQuery.java:252)
    at com.vaadin.data.util.sqlcontainer.SQLContainer.getPropertyIds(SQLContainer.java:1194)
    at com.vaadin.data.util.sqlcontainer.SQLContainer.<init>(SQLContainer.java:134)
    at info.chrismcgee.sky.vaadinsqltest.dbutil.VaadinConnManager.getJobs(VaadinConnManager.java:38)
    at info.chrismcgee.sky.vaadinsqltest.VaadinsqltestUI$1.buttonClick(VaadinsqltestUI.java:41)
    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:483)
    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
    at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:977)
    at com.vaadin.ui.Button.fireClick(Button.java:393)
    at com.vaadin.ui.Button$1.click(Button.java:61)
    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:483)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:291)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:184)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:92)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:350)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    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:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
    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)

com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'LIMIT'.

第9行显示&#34;属性ID&#34;警告,以下行是异常本身。再往下,在第24行,您将看到我班级中发生错误的位置。请注意行号:38。如果您在上面的源代码中看到,第38行包含一个注释掉的行。如果我添加更多空行或稍微移动一些东西,错误将保留在第38行。

1 个答案:

答案 0 :(得分:0)

尝试在Derby数据库中打开表时,我收到了类似的错误消息。 我的问题(SQLException)的原因是Derby不理解SQL语句

  

SELECT * FROM .... LIMIT 20,40;

当Vaadin通过a显示网格中的下一页行时,需要仅获取数字为20到40的行(在此示例中),以实现有效的分页/延迟加载     com.vaadin.data.util.sqlcontainer.query.TableQuery

限制子句在

中生成
com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator.generateLimits(StringBuffer, int, int)

实际上Vaadin有一个专门的MS-SQL服务器类 - 所以它应该工作:      com.vaadin.data.util.sqlcontainer.query.generator.MSSQLGenerator

(您可以通过Eclipse Explorer打开源代码&gt; Libraries&gt; Ivy&gt; vaadin-server-7.4.0-sources.jar&gt; .. package ..)