所以我試圖做一個簡單的測試,我的Vaadin程序將簡單地連接到MS SQL Server數據庫並檢索一些數據。沒什麼大不了。除了Vaadin想要做一件大事。不明原因的Vaadin錯誤
我不知道發生了什麼事,但我現在在一個點上我。不管什麼樣的變化我要對我的VaadinConnManager
類,我得到完全相同的的錯誤信息(「附近有語法錯誤‘限制’」 )在完全相同的行號,即使該行號沒有任何內容。這就像程序是卡住在一個特定的修訂版,並不會接受任何其他更改。
我認爲這至少部分與我在Eclipse中遇到的奇怪錯誤有關。這裏是什麼樣子:
我已經盤旋了兩個圖標,是相關的。通常,「紅色X」圖標表示程序中存在錯誤,通常位於.java
源文件之一中。但正如你所看到的,我的任何源文件都沒有這樣的錯誤。 「Java Resources」文件夾中似乎還有一個剪輯感嘆號。我認爲小地球圖標只是隱藏了它的上半部分,這就是它看起來像一個紅色沙漏的原因。而不是紅色的感嘆號。 Eclipse不能告訴我這些錯誤是什麼。或者,至少,我無法弄清楚。無可否認,我仍然在學習Eclipse,所以完全有可能我只是不知道在哪裏尋找解釋這些紅色標記。誰能幫幫我嗎?
編輯(2015年4月8日):我從兩個.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行顯示「property id」警告,並且以下行本身是異常。再往下,在第24行,你會看到我的班級發生錯誤。請注意行號:38.如果您在上面的源代碼中看到,第38行包含註釋行。如果我添加更多的空行或移動一些東西,錯誤留在行號38上。
對。我之前沒有發佈我的代碼,但現在我正在編輯我的原始帖子。看看這段代碼,你會發現我確實使用MSSQLGenerator來處理TableQuery。但是,無論如何,當我切換到使用FreeformQuery時,所有對TableQuery的引用都被註釋掉了。但是,當代碼運行時,會引用第38行的錯誤,該錯誤現在已被註釋掉。 我也做了另一個項目,複製這個到最後的細節,它工作得很好。沒有意義。它必須與Eclipse有關。 – Sturm