开发者

How to set the oracle.jdbc.V8Compatible property

I am using Oracle 10g with a Grails 1.3.2 application. I am targeting a legacy schema with all Date columns types used where time is stored. I believe I need to set the oracle.jdbc.V8Compatible property to true somewhere in order to开发者_JAVA百科 use Groovy's Sql.rows instance method (which uses ResultSet.getObject under the hood) to get java.sql.Timestamp objects with time components preserved instead java.sql.Date objects with time component truncated (see this). Where is the right / best place to set / how do I set the oracle.jdbc.V8Compatible property in a Grails application?

we use DataSource.groovy for development, and a JBoss JNDI configuration for production.


For the development environment I suggest to specify it in DataSource.groovy:

dataSource {
    // common settings          
}
environments {
    development {
        dataSource {
            properties = "oracle.jdbc.V8Compatible=true"
        }
    }   
}

For production you have to put this in the connection-property field for the datasource.


I abandoned the Sql.rows / V8Compatibility approach and instead am just using a custom function:

public static java.sql.Timestamp sqlScalarTimestamp(dataSource, query, params) {
    Sql sql;
    try {
        sql = new Sql(dataSource)
        def result = null
        sql.query(query, params) { rs ->
            if(rs.next())
                result = rs.getTimestamp(1)
        }
        return result
    } finally {
        if(sql != null)
            sql.close()
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜