2016-10-20 80 views
-7

我從sql中填充第二個Ftable時出現此錯誤。爲什麼我在我的java代碼中出現這個錯誤?

[EL Info]: 2016-10-20 11:13:45.547--ServerSession(18652179)--EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd 
[EL Info]: connection: 2016-10-20 11:13:46.556--ServerSession(18652179)--file:/C:/Users/Talha/Desktop/SADIQUE ELECTRIC/build/classes/_clientdb?zeroDateTimeBehavior=convertToNullPU login successful 
[EL Warning]: 2016-10-20 11:13:46.708--UnitOfWork(25880107)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException 
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-brand' at line 1 
Error Code: 1064 
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException 
Call: SELECT id, amps, comingA, comingB, g1, gTotal, hp, model, mr, newOrderA, newOrderB, totalImport FROM clientdb.selco-brand 
Query: ReadAllQuery(referenceClass=SelcoBrand_1 sql="SELECT id, amps, comingA, comingB, g1, gTotal, hp, model, mr, newOrderA, newOrderB, totalImport FROM clientdb.selco-brand") 
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-brand' at line 1 
Error Code: 1064 
Call: SELECT id, amps, comingA, comingB, g1, gTotal, hp, model, mr, newOrderA, newOrderB, totalImport FROM clientdb.selco-brand 
Query: ReadAllQuery(referenceClass=SelcoBrand_1 sql="SELECT id, amps, comingA, comingB, g1, gTotal, hp, model, mr, newOrderA, newOrderB, totalImport FROM clientdb.selco-brand") 
    at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:378) 
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:260) 
    at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469) 
    at sadique.electric.selcoBrand.initComponents(selcoBrand.java:33) 
    at sadique.electric.selcoBrand.<init>(selcoBrand.java:18) 
    at sadique.electric.selcoBrand$1.run(selcoBrand.java:132) 
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) 
    at java.awt.EventQueue.access$500(EventQueue.java:97) 
    at java.awt.EventQueue$3.run(EventQueue.java:709) 
    at java.awt.EventQueue$3.run(EventQueue.java:703) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) 
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) 
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException 
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-brand' at line 1 
Error Code: 1064 
Call: SELECT id, amps, comingA, comingB, g1, gTotal, hp, model, mr, newOrderA, newOrderB, totalImport FROM clientdb.selco-brand 
Query: ReadAllQuery(referenceClass=SelcoBrand_1 sql="SELECT id, amps, comingA, comingB, g1, gTotal, hp, model, mr, newOrderA, newOrderB, totalImport FROM clientdb.selco-brand") 
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340) 
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:682) 
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558) 
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2002) 
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570) 
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242) 
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228) 
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299) 
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:694) 
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2738) 
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2691) 
    at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:495) 
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1168) 
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899) 
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1127) 
    at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403) 
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1215) 
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896) 
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804) 
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786) 
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1751) 
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258) 
    ... 18 more 
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-brand' at line 1 
    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:423) 
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) 
    at com.mysql.jdbc.Util.getInstance(Util.java:386) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052) 
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503) 
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664) 
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2794) 
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155) 
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322) 
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:1007) 
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:642) 
    ... 38 more 
+0

請提供更多的背景; 'sadique.electric.selcoBrand.initComponents(selcoBrand.java:33)'(我認爲是你的代碼)究竟發生了什麼,你想做什麼,到目前爲止你嘗試過什麼,等等。簡單地發佈堆棧跟蹤沒有其他的背景就像是當你只說「我聽到一種噪音」時,期待你的機械師修理你的車。 – dimo414

+4

閱讀該消息... y原因存在... –

+0

MySQLSyntaxErrorException:您的SQL語法中有錯誤;檢查與你的MariaDB服務器版本相對應的手冊,在第1行'-brand'附近使用正確的語法錯誤代碼:1064調用:SELECT id,amps,comingA,comingB,g1,gTotal,hp,model,mr,newOrderA ,newOrderB,totalImport FROM clientdb.selco-brand查詢: –

回答

1

在本節

... FROM clientdb.selco-brand 

表名selco-brand包含一個連字符,所以表的名稱必須使用反引號被引用:

... FROM clientdb.`selco-brand` 
相關問題