2016-10-20 19 views
-7

SQLから2番目の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、amp、comingA、comingB、g1、gTotal、hp、model、mr、newOrderA 、newOrderB、totalImport FROM clientdb.selco-brand Query: –

答えて

1
この句で

... FROM clientdb.selco-brand 

テーブル名selco-brandはハイフンが含まれているので、テーブル名はバッククォートを使用して引用されている必要があります

... FROM clientdb.`selco-brand` 
関連する問題