java.sql.SQLSyntaxErrorException:错误 de sintaxis:遇到“USER”和“ORDER”

问题描述 投票:0回答:1

我正在 Netbeans 上做一个项目,使用 Glassfish 和 jdbc。我正在使用 JSP 处理一些视图,我的项目突然崩溃了。我尝试寻找解决方案但无法解决它。这是我得到的错误:

  EclipseLink, version: Eclipse Persistence Services - 4.0.2.v202306161219|#]
  Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 4.0.2.v202306161219): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Error de sintaxis: Encountered "USER" at line 1, column 14.
Error Code: 30000
Call: CREATE TABLE USER (IDUSER BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, ADDRESS VARCHAR(255), EMAIL VARCHAR(255), NAME VARCHAR(255), PASSWORD VARCHAR(255), PHONE INTEGER, ROL VARCHAR(255), USERNAME VARCHAR(255), PRIMARY KEY (IDUSER))
Query: DataModifyQuery(sql="CREATE TABLE USER (IDUSER BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, ADDRESS VARCHAR(255), EMAIL VARCHAR(255), NAME VARCHAR(255), PASSWORD VARCHAR(255), PHONE INTEGER, ROL VARCHAR(255), USERNAME VARCHAR(255), PRIMARY KEY (IDUSER))")
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:343)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:702)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:569)
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2048)
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:611)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:280)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:266)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:323)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:294)
    at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:88)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:913)
    at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3308)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1841)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1823)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1773)
    at org.eclipse.persistence.internal.sessions.AbstractSession.priviledgedExecuteNonSelectingCall(AbstractSession.java:5055)
    at org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition.createOnDatabase(DatabaseObjectDefinition.java:205)
    at org.eclipse.persistence.tools.schemaframework.SchemaManager.createObject(SchemaManager.java:224)
    at org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:189)
    at org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:159)
    at org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:151)
    at org.eclipse.persistence.tools.schemaframework.SchemaManager.createDefaultTables(SchemaManager.java:1034)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.generateDefaultTables(EntityManagerFactoryProvider.java:116)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDLToDatabase(EntityManagerSetupImpl.java:4731)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeMetadataDDLToDatabase(EntityManagerSetupImpl.java:4798)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:4697)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:4570)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:816)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:221)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:199)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:534)
    at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:385)
    at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:313)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:222)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:126)
    at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:318)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:545)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:325)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:984)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:467)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:257)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:471)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:569)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:565)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/javax.security.auth.Subject.doAs(Subject.java:453)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:564)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:595)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:587)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/javax.security.auth.Subject.doAs(Subject.java:453)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:586)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1477)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:536)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:223)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:150)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:425)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515)
    at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.sql.SQLSyntaxErrorException: Error de sintaxis: Encountered "USER" at line 1, column 14.
    at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:94)
    at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:325)
    at org.apache.derby.client.am.ClientConnection.prepareStatement(ClientConnection.java:448)
    at com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:497)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1750)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1697)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:770)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:630)
    ... 75 more
Caused by: ERROR 42X01: Error de sintaxis: Encountered "USER" at line 1, column 14.
    at org.apache.derby.client.am.ClientStatement.completeSqlca(ClientStatement.java:2116)
    at org.apache.derby.client.net.NetStatementReply.parsePrepareError(NetStatementReply.java:579)
    at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(NetStatementReply.java:145)
    at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(NetStatementReply.java:54)
    at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(StatementReply.java:41)
    at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(NetStatement.java:156)
    at org.apache.derby.client.am.ClientStatement.readPrepareDescribeOutput(ClientStatement.java:1702)
    at org.apache.derby.client.am.ClientPreparedStatement.readPrepareDescribeInputOutput(ClientPreparedStatement.java:1914)
    at org.apache.derby.client.am.ClientPreparedStatement.flowPrepareDescribeInputOutput(ClientPreparedStatement.java:1977)
    at org.apache.derby.client.am.ClientPreparedStatement.prepare(ClientPreparedStatement.java:315)
    at org.apache.derby.client.am.ClientConnection.prepareStatementX(ClientConnection.java:1956)
    at org.apache.derby.client.am.ClientConnection.prepareStatement(ClientConnection.java:435)
    ... 80 more
|#]
  Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 4.0.2.v202306161219): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Error de sintaxis: Encountered "ORDER" at line 1, column 14.
Error Code: 30000
Call: CREATE TABLE ORDER (IDORDER BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, DATE TIMESTAMP, STATE VARCHAR(255), TOTAL FLOAT, idUser BIGINT, PRIMARY KEY (IDORDER))
Query: DataModifyQuery(sql="CREATE TABLE ORDER (IDORDER BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, DATE TIMESTAMP, STATE VARCHAR(255), TOTAL FLOAT, idUser BIGINT, PRIMARY KEY (IDORDER))")
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:343)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:702)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:569)
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2048)
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:611)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:280)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:266)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:323)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:294)
    at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:88)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:913)
    at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3308)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1841)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1823)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1773)
    at org.eclipse.persistence.internal.sessions.AbstractSession.priviledgedExecuteNonSelectingCall(AbstractSession.java:5055)
    at org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition.createOnDatabase(DatabaseObjectDefinition.java:205)
    at org.eclipse.persistence.tools.schemaframework.SchemaManager.createObject(SchemaManager.java:224)
    at org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:189)
    at org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:159)
    at org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:151)
    at org.eclipse.persistence.tools.schemaframework.SchemaManager.createDefaultTables(SchemaManager.java:1034)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.generateDefaultTables(EntityManagerFactoryProvider.java:116)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDLToDatabase(EntityManagerSetupImpl.java:4731)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeMetadataDDLToDatabase(EntityManagerSetupImpl.java:4798)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:4697)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:4570)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:816)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:221)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:199)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:534)
    at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:385)
    at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:313)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:222)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:126)
    at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:318)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:545)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:325)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:984)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:467)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:257)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:471)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:569)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:565)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/javax.security.auth.Subject.doAs(Subject.java:453)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:564)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:595)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:587)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/javax.security.auth.Subject.doAs(Subject.java:453)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:586)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1477)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:536)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:223)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:150)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:425)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515)
    at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.sql.SQLSyntaxErrorException: Error de sintaxis: Encountered "ORDER" at line 1, column 14.
    at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:94)
    at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:325)
    at org.apache.derby.client.am.ClientConnection.prepareStatement(ClientConnection.java:448)
    at com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:497)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1750)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1697)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:770)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:630)
    ... 75 more
Caused by: ERROR 42X01: Error de sintaxis: Encountered "ORDER" at line 1, column 14.
    at org.apache.derby.client.am.ClientStatement.completeSqlca(ClientStatement.java:2116)
    at org.apache.derby.client.net.NetStatementReply.parsePrepareError(NetStatementReply.java:579)
    at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(NetStatementReply.java:145)
    at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(NetStatementReply.java:54)
    at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(StatementReply.java:41)
    at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(NetStatement.java:156)
    at org.apache.derby.client.am.ClientStatement.readPrepareDescribeOutput(ClientStatement.java:1702)
    at org.apache.derby.client.am.ClientPreparedStatement.readPrepareDescribeInputOutput(ClientPreparedStatement.java:1914)
    at org.apache.derby.client.am.ClientPreparedStatement.flowPrepareDescribeInputOutput(ClientPreparedStatement.java:1977)
    at org.apache.derby.client.am.ClientPreparedStatement.prepare(ClientPreparedStatement.java:315)
    at org.apache.derby.client.am.ClientConnection.prepareStatementX(ClientConnection.java:1956)
    at org.apache.derby.client.am.ClientConnection.prepareStatement(ClientConnection.java:435)
    ... 80 more
|#]
  Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 4.0.2.v202306161219): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Error de sintaxis: Encountered "ORDER" at line 1, column 13.
Error Code: 30000
Call: ALTER TABLE ORDER ADD CONSTRAINT FK_ORDER_idUser FOREIGN KEY (idUser) REFERENCES USER (IDUSER)
Query: DataModifyQuery(sql="ALTER TABLE ORDER ADD CONSTRAINT FK_ORDER_idUser FOREIGN KEY (idUser) REFERENCES USER (IDUSER)")
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:343)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:702)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:569)
    at 

然后

Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalStateException: CDI is not available
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:116)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:97)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:262)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:353)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:533)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:257)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:471)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:569)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:565)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/javax.security.auth.Subject.doAs(Subject.java:453)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:564)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:595)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:587)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/javax.security.auth.Subject.doAs(Subject.java:453)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:586)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1477)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)

请记住,我是一名大学一年级学生,所以我根本没有经验。谢谢!

更新:现在我收到此错误: 在ExternalContext 中未找到/index.xhtml 作为资源

我查了一下,有人说这是因为项目结构的原因,这是我的:

C:.
│   build.xml
│
├───build
│   ├───empty
│   ├───generated-sources
│   │   └───ap-source-output
│   └───web
│       │   gfv700ee10.dpf
│       │   index.html
│       │
│       ├───css
│       │       main.css
│       │
│       ├───js
│       │       functions.js
│       │
│       ├───META-INF
│       │       MANIFEST.MF
│       │
│       └───WEB-INF
│           │   glassfish-web.xml
│           │
│           ├───classes
│           │   │   .netbeans_automatic_build
│           │   │   .netbeans_update_resources
│           │   │
│           │   ├───daw
│           │   │   ├───controllers
│           │   │   │       ProductController.class
│           │   │   │
│           │   │   └───model
│           │   │           Product.class
│           │   │
│           │   └───META-INF
│           │           persistence.xml
│           │
│           └───views
│                   error.jsp
│                   formProduct.jsp
│                   products.jsp
│
├───nbproject
│   │   ant-deploy.xml
│   │   build-impl.xml
│   │   genfiles.properties
│   │   project.properties
│   │   project.xml
│   │
│   └───private
│           private.properties
│           private.xml
│
├───setup
│       glassfish-resources.xml
│
├───src
│   ├───conf
│   │       MANIFEST.MF
│   │       persistence.xml
│   │
│   └───java
│       └───daw
│           ├───controllers
│           │       ProductController.java
│           │
│           └───model
│                   Product.java
│
├───test
└───web
    │   index.html
    │
    ├───css
    │       main.css
    │
    ├───js
    │       functions.js
    │
    └───WEB-INF
        │   glassfish-web.xml
        │
        └───views
                error.jsp
                formProduct.jsp
               
java sql jdbc derby
1个回答
0
投票

SQL 关键字

您使用的名称恰好是某些 SQL 方言中的关键字:

USER
ORDER

解决方案:

  • 在名称两边使用引号,以防止单词被视为关键字。
  • 使用不同的名称。
    • 我建议为每个名称添加尾随下划线。 SQL 标准规范明确承诺永远不会在任何关键字中使用尾随下划线。

所以:

USER_
&
ORDER_

此外,SQL 标准要求实现以全大写形式存储名称。但我所知道的每一个实施都未能遵守。因此,为了获得最大的可移植性,请在名称中使用全小写字母。

所以:

user_
&
order_

© www.soinside.com 2019 - 2024. All rights reserved.