netbeans DERBY SQL错误:错误代码:40000,SQL状态:XJ041、SQLERRMC:无法创建数据库“sun-appserv-samples”

rbl8hiat  于 2022-11-10  发布在  其他
关注(0)|答案(1)|浏览(537)

我正在学习第一个cup教程,但是我在chapter 4的结尾处卡住了,有以下例外:
java.sql.SQLException:分配连接时出错。原因:无法分配连接,因为:DERBY SQL错误:错误代码:40000,SQL状态:XJ041、SQLERRMC:无法创建数据库“sun-appserv-samples”,请参阅下一个异常以了解详细信息。::SQLSTATE:XBM 01::SQL状态:新佳001
在“项目”选项卡中,我选择firstcup-war项目,右键单击并选择“运行”。
输出选项卡显示:

Deploying on GlassFish Server
    profile mode: false
    debug mode: false
    force redeploy: true
In-place deployment at /home/t/NetBeansProjects/firstcup-war/target/firstcup-war
GlassFish Server, deploy, null, false

"Java DB数据库进程“选项卡显示

Fri May 08 21:09:39 CEST 2020 : Security manager installed using the Basic server security policy.
Fri May 08 21:09:39 CEST 2020 : Apache Derby Network Server - 10.14.2.0 - (1828579) started and ready to accept connections on port 1527

标签 GlassFish Server 有一长串异常:

...
Info:   EclipseLink, version: Eclipse Persistence Services - 2.7.0.v20170811-d680af5
Warning:   RAR5038:Unexpected exception while creating resource for pool DerbyPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Warning:   RAR5117 : Failed to obtain/create connection from connection pool [ DerbyPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Warning:   RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001]
Severe:   Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Error Code: 0
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:316)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:147)
    at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:170)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:228)
    [...]

Severe:   Exception while deploying the app [firstcup-war]
Severe:   Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Error Code: 0
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:844)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:216)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:324)
    at 
    ...

Severe:   Exception while deploying the app [firstcup-war] : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Error Code: 0

我不确定哪些部分是相关的,因为这里有完整的日志:https://pastebin.com/cRE9mVMQ

icomxhvb

icomxhvb1#

我不能确定,因为我没有看到您的derby日志,但它可能与Java权限错误有关。
如果derby.log中出现以下情况:

Java exception: 'access denied ("java.lang.RuntimePermission" "getenv.SOURCE_DATE_EPOCH"")

请参阅this answer
我通过添加以下内容解决了问题

permission java.lang.RuntimePermission "getenv.SOURCE_DATE_EPOCH";

/etc/java-11-openjdk/security/java.policy(Ubuntu)的版本。

相关问题