从返回的Oracle时间戳列中检索数据 [英] Retrieving Data From Returned Oracle Timestamp Column
问题描述
我们有一个使用Oracle时间戳的ColdFusion 8(Linux)应用程序.我们刚刚从10g转换为Oracle 11g,现在我们在数据源上使用Oracle的瘦客户机.在选择时间戳列的应用程序中出现错误.
We have a ColdFusion 8 (Linux) application that uses an Oracle timestamp. We just converted to Oracle 11g from 10g and we're now using Oracle's thin client on the data sources. We're getting an error in the application where a timestamp column is selected.
似乎正在返回类 oracle.sql.TIMESTAMP
的对象.我通过转储列的内容来验证这一点.果然,它使我可以分解对象的方法及其返回类型.但是,我似乎无法直接与此对象交互:
It seems as though an object of class oracle.sql.TIMESTAMP
is being returned. I verified this by dumping the contents of the column. Sure enough, it gives me a break down of the object's methods and their return types. But, I can't seem to be able to interface with this object directly:
<cfquery name="getstuff" ...>
SELECT timestampfld ...
FROM myTable
</cfquery>
getstuff.timestampfld
包含一个对象.但是,这样做:
getstuff.timestampfld
contains an object. But, doing this:
<cfoutput query="getstuff">
#timestampfld.stringValue()#
#timestampfld.dateValue()#
</cfoutput>
产生错误,指出找不到这些方法.如何获取该对象中保存的数据?
produces the error that says those methods can't be found. How can I get at the data held in that object?
评论更新:
当我获取列值并对其应用 DateFormat(timestampfld,"dd.mm.yyyy")
函数时.CF错误为
When I take column value and apply the DateFormat( timestampfld, "dd.mm.yyyy" )
function to it. The CF error is
"The value class oracle.sql.timestamp cannot be converted to a date".
当我执行< cfoutput>
时,我得到了类定义.
When I perform <cfoutput>
, I get the class definition.
在检索的列中,我似乎正在获取对象而不是字符串.当我cfdump列时,我得到oracle.sql.TIMESTAMP的对象.转储列出了可用的方法和字段.当我输出相同的变量时,将显示一个字符串.当我尝试对该变量执行 DataFormat()
时,它抱怨说它不是日期.
In the retrieved column, I seem to be getting an object instead of a string. When I cfdump the column, I get OBJECT OF oracle.sql.TIMESTAMP. The dump lays out the methods and fields available. When I cfoutput that same variable, a string is displayed. When I try to perform a DataFormat()
on the variable, it complains that its not a date.
推荐答案
在开发过程中,我偶然偶然发现了此错误.我过去曾经拥有它,此后早已被人们遗忘.我知道两种缓解方法:第一种是根据有关不同上下文中相同错误消息的问题的答案.可以将以下内容添加到 jvm.config
文件
I just happened to stumble over this error during my development. I had it in the past and long forgotten since.
I know of two ways to mitigate:
The first is according to an answer of a question regarding the same error message in a different context.
One would add the following to the jvm.config
file
-Doracle.jdbc.J2EE13Compliant=true
第二种方法是不返回Oracle TIMESTAMP列,而是先对其进行CAST操作,例如,
The second is not to return an Oracle TIMESTAMP column but CAST it do DATE, first, like
<cfquery name="getstuff" ...>
SELECT CAST( timestampfld as DATE ) timestampfld
FROM myTable
</cfquery>
说实话,我也不满意.忘记JVM参数后,软件将崩溃.另一方面,CAST可能会影响SQL的工作方式.
I'm not satisfied with either, to be honest. When the JVM argument is forgotten, the software crashes. The CAST, on the other hand, may influence how the SQL works.
这篇关于从返回的Oracle时间戳列中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!