> Hi
>
[quoted text clipped - 3 lines]
> isolate the problem by testing against a very simple table and with a
> simple test application.
Hi. I suspect your problem is that you're using a very old
version of the thin driver. Try downloading a new one from
Oracle. Also, don't call getDate() to get the data unless
you specifically want to lose the time portion of the data.
GetTimeStamp() is the right call.
HTH,
Joe Weinstein at BEA Systems
> Here's the table:
>
[quoted text clipped - 101 lines]
>
> Thanks
mdwoolley - 30 Dec 2005 10:22 GMT
Thanks Joe. You're probably right. After more
banging-of-head-against-wall I spotted the usual "schoolboy error". I
was using the thin driver for Java 1.3 rather than 1.4. I was getting
various other strange results, over and above the date related stuff.
These miscellaneous issues have now gone away but I have yet to retest
the original problem, having given up and decided to store my dates as
milliseconds since 1970 values.
I'll dig out the test program again and see if I can now handle dates
as expected.
Thanks for posting.
Martin
mdwoolley - 30 Dec 2005 10:41 GMT
OK, I re-ran the test app, having modified it to use getTimestamp().
Unfortunately it now fails on executing the select * from test
statement with:
About to execute SELECT
Exception in thread "main" java.sql.SQLException: Bigger type length
than Maximum
Any idea why it would do this?
Thanks in anticipation
Martin
Joe Weinstein - 30 Dec 2005 16:59 GMT
> OK, I re-ran the test app, having modified it to use getTimestamp().
> Unfortunately it now fails on executing the select * from test
[quoted text clipped - 9 lines]
>
> Martin
These are all internal Oracle problems. Hmmmm....
I just ran this code:
System.out.println("The driver is " + c.getMetaData().getDriverVersion() );
System.out.println("The DBMS is " + c.getMetaData().getDatabaseProductVersion() );
Statement s = c.createStatement();
try{s.executeUpdate("drop table joetest");} catch (Exception ignore){}
s.executeUpdate("create table joetest(bar timestamp )");
Timestamp t = new java.sql.Timestamp((new java.util.Date()).getTime());
System.out.println( t );
PreparedStatement p = c.prepareStatement("insert into joetest values(?)");
p.setTimestamp(1, t);
p.executeUpdate();
ResultSet r = s.executeQuery("select * from joetest");
while (r.next()) System.out.println( r.getTimestamp(1) );
I got:
The driver is 10.1.0.4.0
The DBMS is Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
2005-12-30 08:56:36.069
2005-12-30 08:56:36.069
Joe Weinstein at BEA Systems
mdwoolley - 30 Dec 2005 17:37 GMT
Hi Joe
good news.....
I ran your code and got:
The driver is 9.2.0.1.0
The DBMS is Oracle9i Release 9.2.0.1.0 - Production
JServer Release 9.2.0.1.0 - Production
2005-12-30 17:31:09.968
2005-12-30 17:31:09.968
And of course the key thing is that I didn't get the "Bigger type.."
error!
So I took a closer look at your code versus mine and noticed that:
Your create table... results in a column of type TIMESTAMP(6) whereas
my schema defination has TIMESTAMP(0). So I changed yours to create a
column as TIMESTAMP(0) and hey presto, the error occurs.
Perhaps I misunderstood the meaning of the parameter in brackets, but I
thought it meant the number of decimal places for fractions of a
second. I wanted accuracy to within a second, so "0" seemed sensible.
Anyway, making mine TIMESTAMP(6) makes things work as I'd originally
wanted.
Thanks for taking the time to help, Joe.
Regards
Martin
Joe Weinstein - 30 Dec 2005 18:10 GMT
> Hi Joe
>
[quoted text clipped - 29 lines]
>
> Martin
I'm glad to help. I tried the timestamp(0), and that
worked for me too (with the latest driver and DBMS),
they must have fixed the issue recently. The (0) means
what you expected it to, but the 9.0 DBMS wasn't truncating
the incoming datum to fit the table column:
s.executeUpdate("create table joetest(bar timestamp(0) )");
The driver is 10.1.0.4.0
The DBMS is Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
2005-12-30 10:06:17.975
2005-12-30 10:06:18.0
Joe Weinstein at BEA Systems
mdwoolley - 31 Dec 2005 06:47 GMT
Excellent!
I'll be testing my application with Oracle 10 next, so it's nice to
know things are probably as they should be at that release. At least
where this issue is concerned! I look forward to uncovering some other
issues instead to drive me a little crazy ;-)
All the best
Martin