Oracle JDBC Driver and Spring 2.0.X Timestamp issue

Oracle JDBC Driver (ojdbc14.jar)

Spring Framework 2.0

import org.springframework.jdbc.support.rowset.SqlRowSet;

public class QueryDAO extends JdbcDaoSupport {

    public SqlRowSet loadSqlRowSet(String sSQL) {
        return getJdbcTemplate().queryForRowSet(sSQL);
    }

}

Using Spring JDBC in such way Timestamp fields are recovered without time information (hours, minutes and seconds set to 0). It seems some issue relative to Sun or Oracle, but there is a workaround in order to achieve desired result.

SqlRowSet rset = 
    jdbcTemplate.queryForRowSet("select cast(sysdate as timestamp) from dual");
while (rset.next()) {
    System.out.println("-> " + 
        ((oracle.sql.TIMESTAMP)rset.getObject(1)).timestampValue());
}

Our batch process failed last night because of this…

Oracle JDBC: Implicit Connection Caching bug exposed

References:

Note. Following code behaves equal in standalone or application server environments.

Right way

// IBM's example
// The following property ordering results in
// a cache being created.

OracleDataSource ods = new OracleDataSource();

ods.setConnectionCachingEnabled(true);
ods.setURL("jdbc:" + "oracle:thin:@localhost:1521:IBM");
ods.setConnectionCacheName("ICC");

ods.setUser("scott");
ods.setPassword("manager1");

Wrong way

// ORACLE's example
// The following property ordering causes no exception,
// but no cache is created.

// create a DataSource
OracleDataSource ods = new OracleDataSource();

// set cache properties
java.util.Properties prop = new java.util.Properties();
prop.setProperty("MinLimit", "2");
prop.setProperty("MaxLimit", "10");

// set DataSource properties
String url = "jdbc:" + "oracle:thin:@";
ods.setURL(url);
ods.setUser("hr");
ods.setPassword("hr");
ods.setConnectionCachingEnabled(true); // be sure set to true
ods.setConnectionCacheProperties (prop);
ods.setConnectionCacheName("ImplicitCache01"); // this cache's name

Oracle documentation includes an example with the incorrect order and has no reference to the bug!

Microsoft Access Long insertion via Jdbc Odbc bridge

This is an old issue:

java.math.BigDecimal type must be used in order to insert java.lang.Long objects in Ms Access databases via Jdbc Odbc brigde.

Reference: Sun Forum