I have a problem about the visualization of all the attribute type "date" only in ORACLE DB. As in the image, the same date value, if I use a formatter the result is true, instead if show the column with standard output I see a false result.
Yes, the problem was the old version of jdbc driver. We have a old oracle db (9) and for this we're using ojdbc14. But now we tried with ojdbc6.jar version 11.1.0.7.0 and it's run. Thanks
Related
We have recently uplifted a major application that was written under JDK6 using ojdbc6 against an 11g Oracle database. It was uplifted to use JDK8 against the same 11g database, but we were also in the midst of upgrading to 12c. The uplifted code has been running in production against the 11g database, but slower than it was before. Against the 12c database in our QA environment, we're noticing jobs either throwing exceptions or running VERY slow. When I looked at the code, I noticed that the project team assigned to uplift the code failed to upgrade the ojdbc from 6 to at least 8. I have since done that work, but now we are getting errors from submitting the following code:
Calendar endModDate = Calendar.getInstance();
// get the timestamp from the db
Query qry = em.createNativeQuery("select SYSTIMESTAMP from dual");
TIMESTAMPTZWrapper tsTZWrapper = (TIMESTAMPTZWrapper)qry.getSingleResult();
The em is our entity manager. But when the code calls the qry.getSingleResult() member function, we get this error:
oracle.sql.TIMESTAMPTZ cannot be cast to org.eclipse.persistence.internal.platform.database.oracle.TIMESTAMPTZWrapper
I've searched high and low for an answer, and anything that resembles an answer doesn't appear to fix my solution. This same logic is used in one other area of the code and produces the same issue. If we switch back to ojdbc6, it then works but we can't use ojdbc6 (and we really shouldn't since we're on jdk8) since we need to upgrade to Oracle 12c in the coming month.
Thanks for any assistance in this matter.
Just quick comment about TIMESTAMP datatype:
There is a bug in JDBC drivers "Bug 21891493 : JDBC SENDS TIMESTAMP SCALE OF NULL WHEN NANOSECONDS ARE ZERO", which can cause creation of excessive number child cursors in Oracle database. This bug was fixed in 12.2 JDBC drivers.
The datatype TIMESTAMP WITH TIMEZONE uses internally a function to convert the this into GMT. When you create an index on it, in some cases this function based index is not used, especially when you compare this column with TIMESTAMP value of different subtype. You should compare exec plans between 11g and 12c.
I'm facing an issue with an update statement that worked earlier in Oracle 9i but now it does not update any rows in Oracle 11G. Here is the statement that i'm using.
update account
set
days_to_validate = validated_date - val_requested_Date
where
validated_date >= val_requested_date
The validated_date and val_requested_date are both date fields in the format: dd-mmm-yyyy (18-Mar-2015). This was working earlier in Oracle 9i before we did an upgrade.
Pls advice on how we can fix this.
Thanks
Prashanth
I was able to fix this. I tried including the "to_date" function and it worked in Oracle 11G. Here is the change i made to the query.
update account
set days_to_validate = to_date(validated_date) - to_date(val_requested_Date)
where to_Date(validated_date) >= to_date(val_requested_date)
I'm new to java db, before this I've always used Microsoft SQL for database programming.
I used SQL Express and Management Studio for database testing and creation.
Now i want to use java db instead, i'm confused about some things about Derby:
What platform i should use to test my database queries as i used Management Studio for SQL.
Secondly, i'm confused about formatting Dates in Derby as i used Set DateFormat function in SQL to format dates. I'm using TimeStamp Datatype and i want my date to be stored in the following format in the database: "Wednesday, August 2014, 11:30 PM"
Please Help!
Derby has an interactive sql client called ij, that can be used to test queries. Look for it in the documentation.
Timestamps are not stored in a particular format. You decide the format when you retrieve the value from the database. E.g.:
CREATE TABLE TIMES(THE_TIME TIMESTAMP);
...
java.sql.Timestamp x = rs.getTimestamp(...);
java.sql.Timestamp is a subclass of java.util.Date and you are free to format the value as you want.
To store a value you just create a java.sql.Timestamp from your input in whatever format it is.
According to the CF9 cfquery documentation, I should be able to return the oracle ROWID in the cfquery result.
I've failed on all counts, it simply does not return any identity or generated keys
I am using the jdbc oracle thin client, can anyone point me in the right direction here?
If you were using one of the Oracle drivers that ships with ColdFusion, then you should be able to access GENERATEDKEY from the RESULT struct within the ColdFusion query object. Since you are using the JDBC Oracle thin client driver, where you setup a data source using "Add a new data source > Other", then enter the JDBC configuration, you don't have access to the RESULT struct described in the documentation.
I ran into the same issue when we used the MS JDBC driver with CF8. After converting to CF9 with the built-in SQL Driver, we were able to update our code to correctly reference the RESULT struct.
You will have to write your INSERT statements to also SELECT the value of ROWID, which you should be able to retrieve from the final query object.
I believe that oracle.jdbc.V8Compatible has been deprecated in Oracle 11
Is this because for a DATE column Oracle is now doing what it did before 8i e.g. return an instance of java.sql.Timestamp for a DATE column?
Their FAQ covers it:
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#08_00
Oracle JDBC 11.1 fixes this problem. Beginning with this release the driver maps SQL DATE columns to java.sql.Timestamp by default. There is no need to set V8Compatible to get the correct mapping. V8Compatible is strongly deprecated. You should not use it at all. If you do set it to true it won't hurt anything, but you should stop using it.
As mentioned above, the 11.1 drivers by default convert SQL DATE to Timestamp when reading from the database. This always was the right thing to do and the change in 9i was a mistake. The 11.1 drivers have reverted to the correct behavior.