且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring JDBC和Firebird数据库

更新时间:2023-02-02 20:52:45

好的,这是操作方法:

将以下内容添加到pom.xml中(两者都需要):

Add the following to your pom.xml (you need both):

    <dependency>
        <groupId>org.firebirdsql.jdbc</groupId>
        <artifactId>jaybird</artifactId>
        <version>2.1.6</version>
    </dependency>
    <dependency>
        <groupId>javax.resource</groupId>
        <artifactId>connector-api</artifactId>
        <version>1.5</version>
    </dependency>

在ApplicationContext文件中将数据源设置为:

Set your datasource in your ApplicationContext file to:

<bean id="dataSource"
    class="org.firebirdsql.pool.FBWrappingDataSource"
    p:database="${jdbc.database}" 
    p:userName="${jdbc.username}"
    p:password="${jdbc.password}" 
    p:type="${jdbc.connection.type}" 
    p:maxPoolSize="5" 
    p:minPoolSize="1"
    p:pooling="true" />

请注意,它使用Firebird专用池,而不是其他数据库那样使用org.apache.commons.dbcp.BasicDataSource.

Note that it uses a Firebird specific pool NOT org.apache.commons.dbcp.BasicDataSource as other databases do.

请注意非标准参数名称.

Note the non-standard parameter names.

这是我的jdbc.properties文件:

Here's my jdbc.properties file:

jdbc.driverClassName=org.firebirdsql.jdbc.FBDriver
jdbc.dialect=org.hibernate.dialect.FirebirdDialect
jdbc.database=/path/to/database.fdb
jdbc.username=admin
jdbc.password=*****
jdbc.defaultAutoCommit=false
jdbc.connection.type=TYPE4

我还不知道如何关闭自动提交功能.抱歉,我正试图找出答案.

I don't know how to set AutoCommit off yet. Sorry, I'm trying to find out.

为什么Firebird不像其他数据库那样成为标准?那么,更多的人可能会使用这个很小的数据库...

Why don't Firebird get this to be STANDARD like other databases? More people might use this great little database then...