ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leon Liu <ljw2...@alibaba-inc.com>
Subject Re: Retrieving Oracle column with data type TIMESTAMP WITH LOCAL TIME ZONE
Date Tue, 18 Mar 2008 16:46:15 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
in some database , pls describe detail a bean's resultmap in xml file
else will cause some problem. <br>
In oracle, date column MUST be TIMESTAMP, the problem cause our site
big problem, all user lose time of HH:mm:ss part. <br>
resultmap define in detail is a good way improve performance. <br>
<br>
<br>
for <font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">Jesse
Reimann:<br>
&nbsp;&nbsp; U can write&nbsp; a column handler for the type .&nbsp; interface
is
TypeHandler, then define the&nbsp; TypeHandler implementation&nbsp; in resultma
p, such as <br>
&lt;result property="gmtLastRepost" column="GMT_LAST_REPOST"
jdbcType="TIMESTAMP" javaType="java.util.Date"&nbsp; typeHandler="your type
handler class name"/&gt;<br>
&nbsp; <br>
</span></font><br>
<br>
Jesse Reimann &#20889;&#36947;:
<blockquote
 cite="mid:B03E298DC8DFC143A7584C166773CBF901A1FCE0@EXCHANGE2K3.ctigroup.com"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta name="Generator" content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
  <style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:blue;
	text-decoration:underline;}
p
	{mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman";}
code
	{font-family:"Courier New";}
span.EmailStyle20
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
  </style>
  <div class="Section1">
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;">Thanks for
the suggestion, but that didn&#8217;t
help since it is the actual oracle jdbc driver that is throwing the
exception
and just setting the session within oracle doesn&#8217;t stop prevent this.<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;">I think I&#8217;m
just going to abandon
this approach and attack the problem from a different angle and handle
all my time
zone conversion stuff explicitly within Oracle. Thinking about it more
setting
a connection level local time zone won&#8217;t solve the business need since
we
need to allow the time zone to be changed on the individual SQL
statement
execution basis.<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;">Jesse<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <div>
  <div class="MsoNormal" style="text-align: center;" align="center"><font
 face="Times New Roman" size="3"><span style="font-size: 12pt;">
  <hr tabindex="-1" align="center" size="2" width="100%"></span></font></div>
  <p class="MsoNormal"><b><font face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font
 face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma;"> Andrey Rogov
[<a class="moz-txt-link-freetext" href="mailto:andrey.rogov@gmail.com">mailto:andrey.rogov@gmail.com</a>]
<br>
  <b><span style="font-weight: bold;">Sent:</span></b> Monday, March
17, 2008 9:43
PM<br>
  <b><span style="font-weight: bold;">To:</span></b>
<a class="moz-txt-link-abbreviated" href="mailto:user-java@ibatis.apache.org">user-java@ibatis.apache.org</a><br>
  <b><span style="font-weight: bold;">Subject:</span></b> Re:
Retrieving Oracle
column with data type TIMESTAMP WITH LOCAL TIME ZONE</span></font><o:p></o:p></p>
  </div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal" style="margin-bottom: 12pt;"><font
 face="Times New Roman" size="3"><span style="font-size: 12pt;">Jess, <br>
&nbsp;&nbsp; try to execute sql operator ALTER SESSION before accessing </span></font><code><font
 face="Courier New" size="2"><span style="font-size: 10pt;">TIMESTAMP
WITH LOCAL
TIME ZONE</span></font></code> data <br>
&nbsp;&nbsp; <br>
&nbsp;&nbsp; &lt;update id="setTimeZone"
parameterClass="java.lang.String"&gt; <br>
&nbsp; &nbsp; &nbsp; &nbsp; ALTER SESSION SET time_zone = #timezonevalue#&nbsp;
  <br>
&nbsp;&nbsp; &lt;/update&gt;<br>
&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp; <o:p></o:p></p>
  <div>
  <p class="MsoNormal"><span class="gmailquote"><font
 face="Times New Roman" size="3"><span style="font-size: 12pt;">2008/3/17,
Jesse Reimann &lt;<a moz-do-not-send="true"
 href="mailto:jreimann@ctigroup.com" target="_blank">jreimann@ctigroup.com</a>&gt;:</span></font></span><o:p></o:p></p>
  <div link="blue" vlink="purple">
  <div>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">I'm
trying to retrieve an Oracle column that is defined as TIMESTAMP WITH
LOCAL
TIME ZONE. Currently I'm receiving an error stating &nbsp;</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font><o:p></o:p></p>
  <p><font color="red" face="Courier New" size="2"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">---
Cause: </span></font><u><font color="navy" face="Courier New" size="2"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: navy;">java.sql.SQLException</span></font></u><font
 color="red" face="Courier New" size="2"><span
 style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;">:
Session Time Zone not set!</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">Looking
into it I need to specify the Session Time Zone as part of the Oracle
JDBC
Connection properties.</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">I
found this in an Oracle document when searching for a solution:</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">&nbsp;</span></font><o:p></o:p></p>
  <p><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">Before
accessing </span></font><code><font face="Courier New" size="2"><span
 style="font-size: 10pt;">TIMESTAMP WITH LOCAL TIME ZONE</span></font></code>
data, call the <code><font face="Courier New" size="2"><span
 style="font-size: 10pt;">OracleConnection.setSessionTimeZone(String
regionName)</span></font></code>
method to set the session time zone. When this method is called, the
JDBC
driver sets the session time zone of the connection and saves the
session time
zone so that any <code><font face="Courier New" size="2"><span
 style="font-size: 10pt;">TIMESTAMP WITH LOCAL TIME ZONE</span></font></code>
data accessed
through JDBC can be adjusted using the session time zone.<o:p></o:p></p>
  <p><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">&nbsp;<o:p></o:p></span></font></p>
  <p><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">&nbsp;<o:p></o:p></span></font></p>
  <p><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">So my
question is how would I go about calling the setSessionTimeZone method
of the
OracleConnection when using iBATIS (and Spring).<o:p></o:p></span></font></p>
  <p><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">&nbsp;<o:p></o:p></span></font></p>
  <p><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">Thanks,<o:p></o:p></span></font></p>
  <p><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">&nbsp;<o:p></o:p></span></font></p>
  <p><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">Jesse
Reimann<o:p></o:p></span></font></p>
  </div>
  </div>
  </div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
  </div>
</blockquote>
<br>
</body>
</html>

Mime
View raw message