代码之家  ›  专栏  ›  技术社区  ›  me_here

在Netbeans中使用Hibernate配置文件连接到Apache Derby时出现问题(错误XSDB6)

  •  1
  • me_here  · 技术社区  · 16 年前

    我已经在Netbeans中创建了一个本地Apache Derby数据库,但是在尝试使用“Hibernate逆向工程向导”自动生成POJO文件时遇到了问题。

    我的Hibernate配置(由Netbeans从数据库连接生成,然后我添加了一些位):

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
     <!-- Default Netbeans generated parameters -->
        <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
        <property name="hibernate.connection.url">jdbc:derby:C:/CerealDatabase</property>
        <property name="hibernate.connection.username">cerealuser</property>
        <property name="hibernate.connection.password">cerealpass</property>
     <!-- Additional parameters -->
     <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
     <property name="hibernate.show_sql">true</property>
     <property name="hibernate.default_schema">CEREALUSER</property>
      </session-factory>
    </hibernate-configuration>
    

    当我尝试使用这个配置文件生成pojo时,我会得到一条消息来检查我的配置文件,derby.log会给出错误:

    java.sql.SQLException: Failed to start database 'C:/CerealDatabase', see the next exception for details.
    Caused by: java.sql.SQLException: Failed to start database 'C:/CerealDatabase', see the next exception for details.
    Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database C:\CerealDatabase.
    

    在尝试此操作之前,我已关闭了与数据库的任何其他连接,并且当时没有“db.lck”锁定文件,这表示没有与数据库的连接(据我所知)。

    有人有什么想法吗?感激地接受了帮助。

    1 回复  |  直到 16 年前
        1
  •  0
  •   Bryan Pendleton    16 年前

    Derby确实使用“锁文件”来记录进程主动打开数据库的时间。您确定没有db.lck文件吗?除了那件事,我从来没见过这条消息。

    作为一个实验,如果从jdbc URL中删除C:,并使用jdbc:derby:/CerealDatabase作为URL,会发生什么?

    推荐文章