嵌入式Firebird数据库和Hibernate

时间:2013-06-12 23:29:45

标签: java database hibernate firebird

我正在尝试将Firebird嵌入式数据库与Hibernate一起使用,但在尝试创建数据库时出现以下错误:

Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544344. I/O error during "CreateFile (open)" operation for file "D:\DB\FIREBIRD.FDB"
Error while trying to open file
null
    at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:123)
    at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:126)
    at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:204)
    at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
    ... 32 more
Caused by: org.firebirdsql.gds.GDSException: I/O error during "CreateFile (open)" operation for file "D:\DB\FIREBIRD.FDB"
Error while trying to open file
null
    at org.firebirdsql.gds.impl.jni.JniGDSImpl.native_isc_attach_database(Native Method)
    at org.firebirdsql.gds.impl.jni.BaseGDSImpl.iscAttachDatabase(BaseGDSImpl.java:158)
    at org.firebirdsql.jca.FBManagedConnection.<init>(FBManagedConnection.java:105)
    at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnection(FBManagedConnectionFactory.java:490)
    at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(FBStandAloneConnectionManager.java:69)
    at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:120)
    ... 36 more

到目前为止我做了什么:

  1. 我已经设置了休眠配置 Driver =“org.firebirdsql.jdbc.FBDriver”,
    Dialect =“org.hibernate.dialect.FirebirdDialect”,
    Url =“jdbc:firebirdsql:embedded:D:\ DB \ FIREBIRD.FDB”,

  2. 我已将 jaybird-full jar添加到我的类路径中。

  3. 我已将 jaybird22.dll fbembed.dll (整个文件夹)添加到我的路径中。

  4. dll似乎被加载,因为如果我删除了我得到的dll并且异常告诉我 jaybird22.dll 找不到。

    知道可能出现什么问题吗?

1 个答案:

答案 0 :(得分:1)

似乎我缺少的一步是手动创建数据库文件:

FBManager manager = new FBManager(GDSType.getType("EMBEDDED"));
manager.start();
manager.createDatabase(myDbFile, username, password);
manager.stop();