Locked History Actions

Diff for "Play/AnormFirebird"

Differences between revisions 1 and 2
Deletions are marked like this. Additions are marked like this.
Line 30: Line 30:
この変更を施したものを以下に添付する。
{{attachment:jaybird-full-2.1.6-ex.jar}}

AnormでFirebirdにアクセス

ここでは、Anorm/Jaybird経由でFirebirdデータベースにアクセスする。

FBDriverNotCapableException

普通にAnormを使おうとすると、この例外が発生する。原因は、めったに使用されないJDBCの機能をAnormが使用しており、jaybirdではその機能を実現しておらず、この例外を発生させているからである。

具体的には、playのAnorm.scalaソース中に

  val s =connection.prepareStatement(sql.query,java.sql.Statement.RETURN_GENERATED_KEYS)

という一文があるが、jaybirdのFBConnection.javaのソースでは

    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
            throws SQLException {
        throw new FBDriverNotCapableException();
    }

としている。とりあえずここを

    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
            throws SQLException {
        return prepareStatement(sql);
    }

と変更すればよい。もちろん、変更したところでjaybirdでこの機能を使うことはできない、つまりシーケンスによる自動連番値の取得はできない。

この変更を施したものを以下に添付する。 jaybird-full-2.1.6-ex.jar