File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes .getObject() and DATE fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark ".getObject() and DATE fields" Watch ".getObject() and DATE fields" New topic

.getObject() and DATE fields

Joel McNary

Joined: Aug 20, 2001
Posts: 1824

So, I had this experience...

I have a generic ResultSet processor that simply takes a result set and creates a list of Maps mapping the column name to the data. This relies heavily on the .getObject() method in ResultSet.

In Oracle 9i and the ojdbc14.jar oracle driver, when I create a query that
returns the value of a DATE field, .getObject() returned a java.sql.Timestamp object.

However, a co-worker had the oracle92.jar slip into his classpath. Apparently there is a driver in that .jar file, and it functions differently -- .getObject() returns an internal Oracle Timestamp type. We removed that .jar file and everything works now, but while we were investigating we found some evidence that this would be the functionality for the Oracle driver going forward (for the drivers for 10g, etc). Now, I don't remember the reference that we found that stated that so I can't reference it here, but my question is basically: Is that correct? And should we be using the oracle92.jar or the ojdbc14.jar?

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Kevin Conaway
Ranch Hand

Joined: Jan 27, 2006
Posts: 57
Hi Joel,

Just as an aside, I am using ojdbc14.jar on an Oracle database and getObject() returns an oracle.sql.Timestamp object (I think) for me.

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Joel McNary:
Is that correct? And should we be using the oracle92.jar or the ojdbc14.jar?

I would go for ojdbc14.jar because not using vendor specific classes is encouraged, until you really want to. As you stated that oracle92.jar is giving you oracle timestamp, I never came across though. Thus, I wouldn't go for it.
I agree. Here's the link:
subject: .getObject() and DATE fields
It's not a secret anymore!