Note that there are some explanatory texts on larger screens.

plurals
  1. POOracle SQL DATE conversion problem using iBATIS via Java JDBC
    primarykey
    data
    text
    <p>I'm currently wrestling with an Oracle SQL DATE conversion problem using iBATIS from Java.</p> <p>Am using the Oracle JDBC thin driver ojdbc14 version 10.2.0.4.0. iBATIS version 2.3.2. Java 1.6.0_10-rc2-b32.</p> <p>The problem revolves around a column of DATE type that is being returned by this snippet of SQL:</p> <pre><code>SELECT * FROM TABLE(pk_invoice_qry.get_contract_rate(?,?,?,?,?,?,?,?,?,?)) order by from_date </code></pre> <p>The package procedure call returns a ref cursor that is being wrapped in a TABLE to where is then easy to read the result set as though were a select query against a table.</p> <p>In PL/SQL Developer, one of the columns returned, FROM_DATE, of SQL DATE type, has precision to time of day:</p> <pre><code>Tue Dec 16 23:59:00 PST 2008 </code></pre> <p>But when I access this via iBATIS and JDBC, the value only retains precision to day:</p> <pre><code>Tue Dec 16 12:00:00 AM PST 2008 </code></pre> <p>This is clearer when displayed like so:</p> <p>Should have been:</p> <pre><code>1229500740000 milliseconds since epoch Tuesday, December 16, 2008 11:59:00 PM PST </code></pre> <p>But getting this instead:</p> <pre><code>1229414400000 milliseconds since epoch Tuesday, December 16, 2008 12:00:00 AM PST (as instance of class java.sql.Date) </code></pre> <p>No matter what I try, I am unable to expose the full precision of this DATE column to be returned via Java JDBC and iBATIS.</p> <p>What iBATIS is mapping from is this:</p> <pre><code>FROM_DATE : 2008-12-03 : class java.sql.Date </code></pre> <p>The current iBATIS mapping is this:</p> <pre><code>&lt;result property="from_date" jdbcType="DATE" javaType="java.sql.Date"/&gt; </code></pre> <p>I've also tried:</p> <pre><code>&lt;result property="from_date" jdbcType="DATETIME" javaType="java.sql.Date"/&gt; </code></pre> <p>or</p> <pre><code>&lt;result property="from_date" jdbcType="TIMESTAMP" javaType="java.sql.Timestamp"/&gt; </code></pre> <p>But all attempted mappings yield the same truncated Date value. It's as though JDBC has already done the damage of losing data precision before iBATIS even touches it.</p> <p>Clearly I'm losing some of my data precision by going through JDBC and iBATIS that is not happening when I stay in PL/SQL Developer running the same SQL snippet as a test script. Not acceptable at all, very frustrating, and ultimately very scary.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload