从数据库导入时出现SQL错误

时间:2014-08-05 08:50:39

标签: java mysql sql eclipse

我已将我的数据库连接到table.swing,当我尝试运行程序时出现错误,我不知道是什么导致它,有谁知道该怎么办?

  

[EL Info]:2014-08-05   10:31:08.419 - ServerSession(1167725985) - EclipseLink,版本:Eclipse   持久性服务 - 2.5.1.v20130918-f2b9fc5 [EL Info]:连接:   2014年8月5日   10:31:08.609 - 的ServerSession(1167725985) - 文件:/ C:/用户/ Ghostk3 /文档/的NetBeansProjects / BassonKochITPAT2014 /建造/类/ ITAppPU   登录成功[EL警告]:2014-08-05   10:31:08.667 - UnitOfWork(1431000052) - 异常[EclipseLink-4002]   (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5):   org.eclipse.persistence.exceptions.DatabaseException内部   例外:java.sql.SQLSyntaxErrorException:Column' EMPLOYEE'是   要么不在FROM列表中的任何表中,要么出现在连接中   规范并且超出了连接规范或范围   出现在HAVING子句中,不在GROUP BY列表中。如果是这样的话   然后是一个CREATE或ALTER TABLE语句' EMPLOYEE'不是专栏   目标表。错误代码:-1呼叫:SELECT EMPLOYEE ID,EMAIL,   EMPLOYEE LASTNAME,员工姓名,从NBUSER.EMPLOYEES开始查询:   ReadAllQuery(referenceClass = Employees sql =" SELECT EMPLOYEE ID,EMAIL,   雇员LASTNAME,员工姓名,从NBUSER.EMPLOYEES")开始   线程中的异常" AWT-EventQueue-0"   javax.persistence.PersistenceException:异常[EclipseLink-4002]   (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5):   org.eclipse.persistence.exceptions.DatabaseException内部   例外:java.sql.SQLSyntaxErrorException:Column' EMPLOYEE'是   要么不在FROM列表中的任何表中,要么出现在连接中   规范并且超出了连接规范或范围   出现在HAVING子句中,不在GROUP BY列表中。如果是这样的话   然后是一个CREATE或ALTER TABLE语句' EMPLOYEE'不是专栏   目标表。错误代码:-1呼叫:SELECT EMPLOYEE ID,EMAIL,   EMPLOYEE LASTNAME,员工姓名,从NBUSER.EMPLOYEES开始查询:   ReadAllQuery(referenceClass = Employees sql =" SELECT EMPLOYEE ID,EMAIL,   雇员LASTNAME,员工姓名,从NBUSER.EMPLOYEES")开始   org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:378)     在   org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:260)     在   org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469)     在bassonkochitpat2014.App2014.initComponents(App2014.java:38)at   bassonkochitpat2014.App2014。(App2014.java:22)at   bassonkochitpat2014.App2014 $ 2.run(App2014.java:199)at   java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)at   java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)at at   java.awt.EventQueue.access $ 400(EventQueue.java:97)at   java.awt.EventQueue $ 3.run(EventQueue.java:697)at   java.awt.EventQueue $ 3.run(EventQueue.java:691)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:714)at   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)   引起:异常[EclipseLink-4002](Eclipse Persistence Services    - 2.5.1.v20130918-f2b9fc5):org.eclipse.persistence.exceptions.DatabaseException内部   例外:java.sql.SQLSyntaxErrorException:Column' EMPLOYEE'是   要么不在FROM列表中的任何表中,要么出现在连接中   规范并且超出了连接规范或范围   出现在HAVING子句中,不在GROUP BY列表中。如果是这样的话   然后是一个CREATE或ALTER TABLE语句' EMPLOYEE'不是专栏   目标表。错误代码:-1呼叫:SELECT EMPLOYEE ID,EMAIL,   EMPLOYEE LASTNAME,员工姓名,从NBUSER.EMPLOYEES开始查询:   ReadAllQuery(referenceClass = Employees sql =" SELECT EMPLOYEE ID,EMAIL,   雇员LASTNAME,员工姓名,从NBUSER.EMPLOYEES")开始   org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)     在   org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:682)     在   org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)     在   org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1991)     在   org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)     在   org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)     在   org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)     在   org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299)     在   org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:694)     在   org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2738)     在   org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2691)     在   org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:495)     在   org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1168)     在   org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)     在   org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1127)     在   org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)     在   org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1215)     在   org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)     在   org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1793)     在   org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1775)     在   org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1740)     在   org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)     ... 18更多引起:java.sql.SQLSyntaxErrorException:Column   ' EMPLOYEE'要么不在FROM列表中的任何表中,要么出现   在连接规范中,并且超出了连接的范围   规范或出现在HAVING子句中,不在GROUP BY中   名单。如果这是一个CREATE或ALTER TABLE语句,那么' EMPLOYEE'是   不是目标表中的列。在   org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(未知   来源)at   org.apache.derby.client.am.SqlException.getSQLException(未知   来源)at   org.apache.derby.client.am.Connection.prepareStatement(未知来源)     在   org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1556)     在   org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1505)     在   org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:778)     在   org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:619)     ... 38更多引起:org.apache.derby.client.am.SqlException:   专栏' EMPLOYEE'要么不在FROM列表中的任何表中,要么   出现在连接规范中,超出了范围   加入规范或出现在HAVING子句中并且不在   GROUP BY列表。如果这是一个CREATE或ALTER TABLE语句   ' EMPLOYEE'不是目标表中的列。在   org.apache.derby.client.am.Statement.completeSqlca(未知来源)at   org.apache.derby.client.net.NetStatementReply.parsePrepareError(未知   来源)at   org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(未知   来源)at   org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(未知   来源)at   org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(未知   来源)at   org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput (未知   来源)at   org.apache.derby.client.am.Statement.readPrepareDescribeOutput(未知   来源)at   org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(未知   来源)at   org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(未知   来源)at   org.apache.derby.client.am.PreparedStatement.prepare(未知来源)     在org.apache.derby.client.am.Connection.prepareStatementX(未知   来源)... 43更多建立成功(总时间:3秒)

3 个答案:

答案 0 :(得分:0)

它表示根据此错误,您尝试查询的表中没有EMPLOYEE列:

  

专栏'员工'要么不在FROM列表中的任何表中,要么   出现在连接规范中,超出了范围   加入规范或出现在HAVING子句中并且不在   GROUP BY列表。如果这是一个CREATE或ALTER TABLE语句   ' EMPLOYEE'不是目标表中的列。错误代码:-1来电:   选择员工ID,电子邮件,员工姓名,员工姓名,已开始   来自NBUSER.EMPLOYEES查询:ReadAllQuery(referenceClass = Employees   sql =" SELECT EMPLOYEE ID,EMAIL,EMPLOYEE LASTNAME,EMPLOYEE NAME,   从NBUSER.EMPLOYEES开始#34;)

查询也不正确 - SELECT EMPLOYEE ID, EMAIL, EMPLOYEE LASTNAME, EMPLOYEE NAME,STARTED FROM NBUSER.EMPLOYEES

如果列名为SELECT ID, EMAIL, LASTNAME, NAME, STARTED FROM NBUSER.EMPLOYEES

,请尝试使用:ID, EMAIL, LASTNAME, NAME, STARTED

答案 1 :(得分:0)

似乎查询正在您的表中查找“Employee”列。既然你想拥有 '员工ID'我建议您尝试“Employee.ID”或只是“ID”,因为您只在FROM子句中定义了一个表。

答案 2 :(得分:0)

SQL语句对我来说很可疑:

SELECT EMPLOYEE ID, EMAIL, EMPLOYEE LASTNAME, EMPLOYEE NAME, STARTED FROM NBUSER.EMPLOYEES

SQL认为EMPLOYEE是一个它找不到的列。可能ID,LASTNAME,NAME是有效的列名。

我的建议是让您找出确切的表格定义,并找出为什么" EMPLOYEE"在某些列中显示为前缀。它是您的代码还是来自某些配置文件作为框架的一部分?解决您的问题是微不足道的。为了确保您在开发过程中不会遇到类似的问题,请始终找到根本原因。