??xml version="1.0" encoding="utf-8" standalone="yes"?>中文一区一区三区免费,超碰超碰在线,caoprom在线http://www.aygfsteel.com/terry-zj/zh-cnSat, 17 May 2025 19:31:12 GMTSat, 17 May 2025 19:31:12 GMT60Oracle instant客户端配|?/title><link>http://www.aygfsteel.com/terry-zj/archive/2010/08/30/330216.html</link><dc:creator>Terry的Blog</dc:creator><author>Terry的Blog</author><pubDate>Sun, 29 Aug 2010 17:26:00 GMT</pubDate><guid>http://www.aygfsteel.com/terry-zj/archive/2010/08/30/330216.html</guid><wfw:comment>http://www.aygfsteel.com/terry-zj/comments/330216.html</wfw:comment><comments>http://www.aygfsteel.com/terry-zj/archive/2010/08/30/330216.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/terry-zj/comments/commentRss/330216.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/terry-zj/services/trackbacks/330216.html</trackback:ping><description><![CDATA[<strong>Oracle instant客户端下载地址</strong><br /> <font size="4"><a target="_blank">http://www.oracle.com/<wbr>technetwork/topics/winsoft-<wbr>085727.html</a><br /> </font><a class="boldbodylink" id="file36" name="file36" onclick="youMustAgreePrompt();">instantclient-basic-win32-11.2.0.1.0.zip</a><br /> <font size="4"><br /> <strong>解压?/strong></font><strong>在客L根目录创建tnsnames.ora文g</strong><br /> XE1 = <br /> (DESCRIPTION = <br />   (ADDRESS = (PROTOCOL = TCP)(HOST = 16.157.1.1)(PORT = 1521)) <br /> (CONNECT_DATA = <br /> (SERVER = DEDICATED) <br /> (SERVICE_NAME = XE1) <br /> ) <br /> <br /> XE2 = <br /> (DESCRIPTION = <br />   (ADDRESS = (PROTOCOL = TCP)(HOST = 16.157.1.2)(PORT = 1521)) <br /> (CONNECT_DATA = <br /> (SERVER = DEDICATED) <br /> (SID= XE2) <br /> ) <br /> <br /> 配置PL/SQL Developer<br /> <strong>配置PL/SQL的oracle的目录位|?/strong><br /> tool-->preferences--><wbr>connection-->oracle home ?OCI Library 的\?br /> <br /> 在PL/SQL Developer安装目录下徏立一个start.bat脚本文g<br /> 讄环境变量<br /> set path=C:\instantclient_11_2<br /> set ORACLE_HOME=C:\instantclient_<wbr>11_2<br /> set TNS_ADMIN=C:\instantclient_11_<wbr>2<br /> set NLS_LANG=AMERICAN_AMERICA.<wbr>AL32UTF8<br /> start PLSQLDev.exe <br /> <br /> 具体说明NLS_LANG的取?br /> 格式:NLS_LANG=language_territory.charset <br /> <br /> 取值来?select * from v$nls_parameters <br /> 查询nls的参敎ͼ获得数据库服务器端的字符~码 ,需要保证要讄客户端字W集与服务器端字W集一? <br /> NLS_LANGUAGE <br /> NLS_CHARACTERSET <br /> <br /> <font size="4"><br /> </font> <img src ="http://www.aygfsteel.com/terry-zj/aggbug/330216.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/terry-zj/" target="_blank">Terry的Blog</a> 2010-08-30 01:26 <a href="http://www.aygfsteel.com/terry-zj/archive/2010/08/30/330216.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转发(forward)、包?include)及{?redirect)的区别与联系http://www.aygfsteel.com/terry-zj/archive/2006/10/11/74530.htmlTerry的BlogTerry的BlogWed, 11 Oct 2006 05:41:00 GMThttp://www.aygfsteel.com/terry-zj/archive/2006/10/11/74530.htmlhttp://www.aygfsteel.com/terry-zj/comments/74530.htmlhttp://www.aygfsteel.com/terry-zj/archive/2006/10/11/74530.html#Feedback0http://www.aygfsteel.com/terry-zj/comments/commentRss/74530.htmlhttp://www.aygfsteel.com/terry-zj/services/trackbacks/74530.html说明Q?br />一、forward、include由javax.servlet.RequestDispatcher来封?由包容器container提供RequestDispatcher接口的实玎ͼ其中声明如下Q?br />void forward(ServletRequest req,ServletResponse res)
void include(ServeltRequest req,ServletResponse res)
可以通过两种方式得到RequestDispatcher:
1、ServletContext.getRequestDispatcher(String path);
其中q里的path必须开始ؓ"/"Q即q里的path必须相对于context的root.
2、ServeltRequest.getRequestDispatcher(String path)
q里的path可以为相对\?如果path开始ؓ"/",则也认ؓ是从context的root开始的?br />二、Redirect由HttpServletResponse.sendRedirect(String location)来支?br />差别Q?br />三个都可以对用户的requestq行转发Q但是还是有许多的不同,差别最主要集中在如下几个方面:
1、forward与include׃Request范围内的对象,而redirect则不行,卻I如果一个javabean被声明ؓrequest范围的话Q则被forward到的资源也可以访问这个javabean,而redriect则不行?br />2、forward与include基本上都是{发到context内部的资源,而redirect可以重定向到外部的资?如: req.sendRedriect("
以上来源
http://www.cn-java.com/target/news.php?news_id=3176

?br />struts-config.xml
<forward name="succ"  path="/pages/dynabean2.jsp" redirect="true"/>
讄redirect="true"?转向目标面时效果和redirect一致?br />

Terry的Blog 2006-10-11 13:41 发表评论
]]>
jsp面上调用Batchhttp://www.aygfsteel.com/terry-zj/archive/2006/10/10/74308.htmlTerry的BlogTerry的BlogTue, 10 Oct 2006 07:53:00 GMThttp://www.aygfsteel.com/terry-zj/archive/2006/10/10/74308.htmlhttp://www.aygfsteel.com/terry-zj/comments/74308.htmlhttp://www.aygfsteel.com/terry-zj/archive/2006/10/10/74308.html#Feedback0http://www.aygfsteel.com/terry-zj/comments/commentRss/74308.htmlhttp://www.aygfsteel.com/terry-zj/services/trackbacks/74308.html有这样一个需求,web服务器是sun Soaris5.8 原来有一个java写的Batch打包成jar文g由shell调用 现在要在面上增加一个按钮调用这个shell?br />代码如下Q?br /> struts中的Action

public  ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    
throws  Exception {

    String command 
=   " csh /home/zwfe/shell/zwfecv101.csh " ;
    Process child;
    
try  {
        child 
=  Runtime.getRuntime().exec(command);

        BufferedReader in 
=   new  BufferedReader( new  InputStreamReader(child.getInputStream()));
        String line 
=   "" ;
        
while  ((line  =  in.readLine())  !=   null ) {
            System.out.println(line);
        }
        in.close();

    } 
catch  (IOException e) {
        System.out.println(
" e.getMessage() =  "   +  e.getMessage());
        e.printStackTrace();
    }

    BatchDateDAO dao 
=   new  BatchDateDAO();
    Zwfecw002Form zwfe002form 
=  (Zwfecw002Form) form;
    zwfe002form.setBatchDate(dao.batchDate());

    
return  mapping.findForward( " screen.zwfecw002 " );
}

q里应该注意child = Runtime.getRuntime().exec(command);后需要检查这个Process 是否已经执行完毕Q否则当Action执行完返回后Process 会中断?br />


Terry的Blog 2006-10-10 15:53 发表评论
]]>
如何写一份好的工E师?转蝲http://www.aygfsteel.com/terry-zj/archive/2006/06/23/54605.htmlTerry的BlogTerry的BlogFri, 23 Jun 2006 01:09:00 GMThttp://www.aygfsteel.com/terry-zj/archive/2006/06/23/54605.htmlhttp://www.aygfsteel.com/terry-zj/comments/54605.htmlhttp://www.aygfsteel.com/terry-zj/archive/2006/06/23/54605.html#Feedback0http://www.aygfsteel.com/terry-zj/comments/commentRss/54605.htmlhttp://www.aygfsteel.com/terry-zj/services/trackbacks/54605.html转自 http://googlechinablog.com/2006/06/blog-post_14.html

如何写一份好的工E师?/p>

2006q??4?上午 10:15:00
发表者:王忻QGoogle 工程?

最q三q作?GoogleQ谷歌)的Y件工E师Q我每周会帮Z部门审查历,军_要不要给他们面试。Google q几q的发展让很多许多优U的工E师都前来申诗到目前为止Q我已经看了上千份简历,有些历留下的印象比别的好很多。尤其是最q亲戚朋友常帔R我如何修改他们的历,所以我U篏了一些常见的错误避免的提议,在此跟大家交一下?/p>

1Q谈C做过的技术时Q应该提到用的程序语a、你的个A献和产品l节?/p>

有时我看到有人把q去的经验在历上一W带q,比如_

?在三人小l里Qؓ电子邮g软g写了?features?/p>

q是q远不够的,看简历的人希望了解你做的工作的难度和Ҏ公司有多联p,所以你最好写的具体一些。譬如:

??C++ 语言写了|络电子邮g的自?backups。在三h组里,专门负责设计和写储存服务器。从设计开始, 一q后把这个功?feature 的用hC三千?/p>

2Q多讲事? 用形容词?/p>

看简历的你的历时Q需要做判断Q所以在历里需要事实和数目。如果你写“迅速的提高了Y件的操作效率”,看简历的人很隑ֈ断你成就的难度。但如果你写“在3个星期内Q把软g的操作效率提高了40%?好多了?/p>

有些谦虚的朋友们不愿意把话说满,所以你也可以用q个办法。你如果说自己“突出”或“在目上常常被请去救火”,听v来难免会有点骄傲。但你也可以用不能否认的事实来说明你的观点,如“《纽U日报》评q个产品为‘突出’”,或“加入了三个原本已落后于计划的项目小l,但经q努力和l员一h它们都按时完成了。?/p>

3Q你获得的奖、商业的荣誉或表扬、受用户Ƣ迎的品和你做q的有难度的业余目都该包括在简历里?/p>

我有位朋友在谷一个著名的g公司做了六年Q她设计?IP phoneQ网l电话)为公司赚了上亿的收入Q被公司与商业报道多ơ评了奖。我有一ơ在旧金q高速公路上驾RӞ看到路边有她产品的广告牌Q还有一ơ我M度假时Q竟然发C公路边上也有!

不久Q这位朋友决定换工作Q请我看看她的简历。我惊讶的发玎ͼ她居然轻描E写的写了一?- "1998 ?2004Q网l电话品的g工程师组? 和她的职责?/p>

"产品赢的奖呢Q它为公司赚的钱呢?" 我追问到?/p>

"那些也该写吗Q? 她说?/p>

当然该写?/p>

有h问,业余旉做的目可不可以写?我觉得只要你的项目有代表性能说明对你的能力,都该包括?/p>

4Q分清主ơ,删掉相比之下不v眼的成WQ以免冲淡更加突出的成W?/p>

有朋友问Q写历是不是写的多好Q譬如:

在甲公司做暑假实习生—?br />* 改善电子游戏的数值分cȝ法, 减少了内存要?10%?br />* ?Java 写了 3000 行用L面程序?br />* 每周做两时的h工测试?/p>

你在甌软g工程师的职位Ӟ我觉得前两点比较相关Q第三点其实׃必写了。有时我看到有的历里会提刎ͼ"按时完成了Q务,产品W合原计划规?。但ȝ历的人通常会认是理所当然的,而你把这些声明出来反而减q历的效果?/p>

写一份简历不ҎQ但写好了也会带来成感 Q和好工作!Q?Google Q谷歌)在中国广召各斚w的h才,你不妨可以给我们投个历!我们不但在信息检索方面招雇工E师Q还有计机囑Ş、用L面、硬件、Windows、质量保证员和系l管理员{方面。更多信息,h讉Kq里?/p>

谢谢阅读Q大家感兴趣的话Q下ơ我可以介绍“如何预备Y件工E师的面试”?/p>

Terry的Blog 2006-06-23 09:09 发表评论
]]>
Introducing to Spring FrameworkQ中文修订版Q?转蝲http://www.aygfsteel.com/terry-zj/archive/2006/06/21/54163.htmlTerry的BlogTerry的BlogWed, 21 Jun 2006 03:42:00 GMThttp://www.aygfsteel.com/terry-zj/archive/2006/06/21/54163.htmlhttp://www.aygfsteel.com/terry-zj/comments/54163.htmlhttp://www.aygfsteel.com/terry-zj/archive/2006/06/21/54163.html#Feedback0http://www.aygfsteel.com/terry-zj/comments/commentRss/54163.htmlhttp://www.aygfsteel.com/terry-zj/services/trackbacks/54163.html阅读全文

Terry的Blog 2006-06-21 11:42 发表评论
]]>
VB中动态生成Excel文ghttp://www.aygfsteel.com/terry-zj/archive/2006/05/24/47783.htmlTerry的BlogTerry的BlogWed, 24 May 2006 03:28:00 GMThttp://www.aygfsteel.com/terry-zj/archive/2006/05/24/47783.htmlhttp://www.aygfsteel.com/terry-zj/comments/47783.htmlhttp://www.aygfsteel.com/terry-zj/archive/2006/05/24/47783.html#Feedback1http://www.aygfsteel.com/terry-zj/comments/commentRss/47783.htmlhttp://www.aygfsteel.com/terry-zj/services/trackbacks/47783.html    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
    
    Set xlApp = CreateObject("Excel.Application") '创徏EXCEL对象
    Set xlBook = xlApp.Workbooks.Add    'xlApp.Workbooks.Open("文g?) '打开已经存在的EXCEL工g文?br />    xlApp.Visible = False '讄EXCEL对象可见Q或不可见)
    Set xlSheet = xlBook.Worksheets(1) '讄zd工作?br />    xlSheet.Activate
    xlSheet.Range("C3").Value = "1"
    xlSheet.Cells(1, 1) = "test中文" 'l单元格Qrow,colQ赋?br />   
    ' 画边框线
    xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(2, 2)).Borders.LineStyle = xlContinuous
   
    xlSheet.Rows(1).HorizontalAlignment = xlVAlignCenter '左右居中
    xlSheet.Rows(1).VerticalAlignment = xlVAlignCenter '上下居中

    xlSheet.Cells(iStartRow + idx, 2).HorizontalAlignment = xlVAlignCenter '左右居中
    
    '讄指定列的宽度(单位Q字W个?
    xlApp.ActiveSheet.Columns(1).ColumnWidth = 15

    '讄指定行的高度(单位Q磅)
    xlApp.ActiveSheet.Rows(1).RowHeight = 1 / 0.035
   
    '讄字体
    'xlApp.ActiveSheet.Cells(1, 1).Font.Name = "黑体"

    '讄字体大小
    xlApp.ActiveSheet.Cells(1, 1).Font.Size = 25
   
    '讄整列字体为粗?br />    xlApp.ActiveSheet.Columns(1).Font.Bold = True
   
    'xlBook.SaveAs ("C:\Case1.xls")
   
    'xlSheet.PrintPreview (True)
   
    xlApp.Visible = True '昄文g
   
    'xlSheet.PrintOut '打印工作?br />
    If Not (xlApp Is Nothing) Then
        
        xlBook.Close (True) '关闭工作?br />       
        xlApp.Quit '必须l束EXCEL对象
        Set xlApp = Nothing '释放xlApp对象
    End If



Terry的Blog 2006-05-24 11:28 发表评论
]]>
如何用Java得到Excel中Formula的?/title><link>http://www.aygfsteel.com/terry-zj/archive/2006/05/23/47643.html</link><dc:creator>Terry的Blog</dc:creator><author>Terry的Blog</author><pubDate>Tue, 23 May 2006 06:47:00 GMT</pubDate><guid>http://www.aygfsteel.com/terry-zj/archive/2006/05/23/47643.html</guid><wfw:comment>http://www.aygfsteel.com/terry-zj/comments/47643.html</wfw:comment><comments>http://www.aygfsteel.com/terry-zj/archive/2006/05/23/47643.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/terry-zj/comments/commentRss/47643.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/terry-zj/services/trackbacks/47643.html</trackback:ping><description><![CDATA[工具1QPOI<br />POI是常用的dOffice文g的开源工兗但是在它正式发布的版本中没有提供得到Excel中Formula值的功能?br />q个POIq在开发中的功能。相关信?L<a >http://jakarta.apache.org/poi/hssf/eval.html</a><br /><br />工具2QJExcelAPI<br /><strong>Java Excel API</strong> - A Java API to read, write, and modify Excel spreadsheets<br /><a >http://jexcelapi.sourceforge.net/</a><br />目前的最新版本是2.6 <br /><br /><strong>Some Features</strong><br />* Reads data from Excel 95, 97, 2000, XP, and 2003 workbooks<br />* Reads and writes formulas (Excel 97 and later only)<br />* Generates spreadsheets in Excel 2000 format<br />* Supports font, number and date formatting<br />* Supports shading, bordering, and coloring of cells<br />* Modifies existing worksheets<br />* Is internationalized, enabling processing in almost any locale, country, language, or character encoding (formulas are currently only supported in English, French, * * Spanish, and German, but more can be added if translated)<br />* Supports copying of charts<br />* Supports insertion and copying of images into spreadsheets<br />* Supports logging with Jakarta Commons Logging, log4j, JDK 1.4 Logger, etc<br />...and much more<br /><br /> <br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">  1</span> <span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.io.BufferedWriter;<br /></span><span style="COLOR: #008080">  2</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.io.File;<br /></span><span style="COLOR: #008080">  3</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.io.IOException;<br /></span><span style="COLOR: #008080">  4</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.io.OutputStream;<br /></span><span style="COLOR: #008080">  5</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.io.OutputStreamWriter;<br /></span><span style="COLOR: #008080">  6</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.io.UnsupportedEncodingException;<br /></span><span style="COLOR: #008080">  7</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">  8</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.util.ArrayList;<br /></span><span style="COLOR: #008080">  9</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.util.Iterator;<br /></span><span style="COLOR: #008080"> 10</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 11</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> jxl.Cell;<br /></span><span style="COLOR: #008080"> 12</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> jxl.CellType;<br /></span><span style="COLOR: #008080"> 13</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> jxl.FormulaCell;<br /></span><span style="COLOR: #008080"> 14</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> jxl.Sheet;<br /></span><span style="COLOR: #008080"> 15</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> jxl.Workbook;<br /></span><span style="COLOR: #008080"> 16</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> jxl.biff.CellReferenceHelper;<br /></span><span style="COLOR: #008080"> 17</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> jxl.biff.formula.FormulaException;<br /></span><span style="COLOR: #008080"> 18</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 19</span> <span style="COLOR: #000000"></span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080"> 20</span> <span style="COLOR: #008000"> * Goes through each cell in the workbook, and if the contents of that cell is a<br /></span><span style="COLOR: #008080"> 21</span> <span style="COLOR: #008000"> * formula, it prints out the last calculated value and the formula string<br /></span><span style="COLOR: #008080"> 22</span> <span style="COLOR: #008000"> </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 23</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> Formulas {<br /></span><span style="COLOR: #008080"> 24</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 25</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> main(String[] args) {<br /></span><span style="COLOR: #008080"> 26</span> <span style="COLOR: #000000">        String file </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">jxlrwtest.xls</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 27</span> <span style="COLOR: #000000">        String encoding </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">UTF8</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 28</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> {<br /></span><span style="COLOR: #008080"> 29</span> <span style="COLOR: #000000">            Workbook w </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Workbook.getWorkbook(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> File(file));<br /></span><span style="COLOR: #008080"> 30</span> <span style="COLOR: #000000">            Formulas f </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Formulas(w, System.out, encoding);<br /></span><span style="COLOR: #008080"> 31</span> <span style="COLOR: #000000">            w.close();<br /></span><span style="COLOR: #008080"> 32</span> <span style="COLOR: #000000">        } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (Exception e) {<br /></span><span style="COLOR: #008080"> 33</span> <span style="COLOR: #000000">            e.printStackTrace();<br /></span><span style="COLOR: #008080"> 34</span> <span style="COLOR: #000000">        }<br /></span><span style="COLOR: #008080"> 35</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080"> 36</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 37</span> <span style="COLOR: #000000">    </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080"> 38</span> <span style="COLOR: #008000">     * Constructor<br /></span><span style="COLOR: #008080"> 39</span> <span style="COLOR: #008000">     * <br /></span><span style="COLOR: #008080"> 40</span> <span style="COLOR: #008000">     * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> w<br /></span><span style="COLOR: #008080"> 41</span> <span style="COLOR: #008000">     *            The workbook to interrogate<br /></span><span style="COLOR: #008080"> 42</span> <span style="COLOR: #008000">     * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> out<br /></span><span style="COLOR: #008080"> 43</span> <span style="COLOR: #008000">     *            The output stream to which the CSV values are written<br /></span><span style="COLOR: #008080"> 44</span> <span style="COLOR: #008000">     * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> encoding<br /></span><span style="COLOR: #008080"> 45</span> <span style="COLOR: #008000">     *            The encoding used by the output stream. Null or unrecognized<br /></span><span style="COLOR: #008080"> 46</span> <span style="COLOR: #008000">     *            values cause the encoding to default to UTF8<br /></span><span style="COLOR: #008080"> 47</span> <span style="COLOR: #008000">     * </span><span style="COLOR: #808080">@exception</span><span style="COLOR: #008000"> java.io.IOException<br /></span><span style="COLOR: #008080"> 48</span> <span style="COLOR: #008000">     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 49</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> Formulas(Workbook w, OutputStream out, String encoding)<br /></span><span style="COLOR: #008080"> 50</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> IOException {<br /></span><span style="COLOR: #008080"> 51</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (encoding </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">encoding.equals(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">UnicodeBig</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)) {<br /></span><span style="COLOR: #008080"> 52</span> <span style="COLOR: #000000">            encoding </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">UTF8</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 53</span> <span style="COLOR: #000000">        }<br /></span><span style="COLOR: #008080"> 54</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 55</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> {<br /></span><span style="COLOR: #008080"> 56</span> <span style="COLOR: #000000">            OutputStreamWriter osw </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> OutputStreamWriter(out, encoding);<br /></span><span style="COLOR: #008080"> 57</span> <span style="COLOR: #000000">            BufferedWriter bw </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> BufferedWriter(osw);<br /></span><span style="COLOR: #008080"> 58</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 59</span> <span style="COLOR: #000000">            ArrayList parseErrors </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ArrayList();<br /></span><span style="COLOR: #008080"> 60</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 61</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sheet </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; sheet </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> w.getNumberOfSheets(); sheet</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /></span><span style="COLOR: #008080"> 62</span> <span style="COLOR: #000000">                Sheet s </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> w.getSheet(sheet);<br /></span><span style="COLOR: #008080"> 63</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 64</span> <span style="COLOR: #000000">                bw.write(s.getName());<br /></span><span style="COLOR: #008080"> 65</span> <span style="COLOR: #000000">                bw.newLine();<br /></span><span style="COLOR: #008080"> 66</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 67</span> <span style="COLOR: #000000">                Cell[] row </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 68</span> <span style="COLOR: #000000">                Cell c </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 69</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 70</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> s.getRows(); i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /></span><span style="COLOR: #008080"> 71</span> <span style="COLOR: #000000">                    row </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> s.getRow(i);<br /></span><span style="COLOR: #008080"> 72</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 73</span> <span style="COLOR: #000000">                    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; j </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> row.length; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /></span><span style="COLOR: #008080"> 74</span> <span style="COLOR: #000000">                        c </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> row[j];<br /></span><span style="COLOR: #008080"> 75</span> <span style="COLOR: #000000">                        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (c.getType() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> CellType.NUMBER_FORMULA<br /></span><span style="COLOR: #008080"> 76</span> <span style="COLOR: #000000">                                </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> c.getType() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> CellType.STRING_FORMULA<br /></span><span style="COLOR: #008080"> 77</span> <span style="COLOR: #000000">                                </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> c.getType() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> CellType.BOOLEAN_FORMULA<br /></span><span style="COLOR: #008080"> 78</span> <span style="COLOR: #000000">                                </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> c.getType() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> CellType.DATE_FORMULA<br /></span><span style="COLOR: #008080"> 79</span> <span style="COLOR: #000000">                                </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> c.getType() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> CellType.FORMULA_ERROR) {<br /></span><span style="COLOR: #008080"> 80</span> <span style="COLOR: #000000">                            FormulaCell nfc </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (FormulaCell) c;<br /></span><span style="COLOR: #008080"> 81</span> <span style="COLOR: #000000">                            StringBuffer sb </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> StringBuffer();<br /></span><span style="COLOR: #008080"> 82</span> <span style="COLOR: #000000">                            CellReferenceHelper.getCellReference(c.getColumn(),<br /></span><span style="COLOR: #008080"> 83</span> <span style="COLOR: #000000">                                    c.getRow(), sb);<br /></span><span style="COLOR: #008080"> 84</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 85</span> <span style="COLOR: #000000">                            </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> {<br /></span><span style="COLOR: #008080"> 86</span> <span style="COLOR: #000000">                                bw.write(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Formula in </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> sb.toString()<br /></span><span style="COLOR: #008080"> 87</span> <span style="COLOR: #000000">                                        </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> value:  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> c.getContents());<br /></span><span style="COLOR: #008080"> 88</span> <span style="COLOR: #000000">                                bw.flush();<br /></span><span style="COLOR: #008080"> 89</span> <span style="COLOR: #000000">                                bw.write(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> formula: </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> nfc.getFormula());<br /></span><span style="COLOR: #008080"> 90</span> <span style="COLOR: #000000">                                bw.flush();<br /></span><span style="COLOR: #008080"> 91</span> <span style="COLOR: #000000">                                bw.newLine();<br /></span><span style="COLOR: #008080"> 92</span> <span style="COLOR: #000000">                            } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (FormulaException e) {<br /></span><span style="COLOR: #008080"> 93</span> <span style="COLOR: #000000">                                bw.newLine();<br /></span><span style="COLOR: #008080"> 94</span> <span style="COLOR: #000000">                                parseErrors<br /></span><span style="COLOR: #008080"> 95</span> <span style="COLOR: #000000">                                        .add(s.getName() </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> sb.toString()<br /></span><span style="COLOR: #008080"> 96</span> <span style="COLOR: #000000">                                                </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">: </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> e.getMessage());<br /></span><span style="COLOR: #008080"> 97</span> <span style="COLOR: #000000">                            }<br /></span><span style="COLOR: #008080"> 98</span> <span style="COLOR: #000000">                        }<br /></span><span style="COLOR: #008080"> 99</span> <span style="COLOR: #000000">                    }<br /></span><span style="COLOR: #008080">100</span> <span style="COLOR: #000000">                }<br /></span><span style="COLOR: #008080">101</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080">102</span> <span style="COLOR: #000000">            bw.flush();<br /></span><span style="COLOR: #008080">103</span> <span style="COLOR: #000000">            bw.close();<br /></span><span style="COLOR: #008080">104</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">105</span> <span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (parseErrors.size() </span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">) {<br /></span><span style="COLOR: #008080">106</span> <span style="COLOR: #000000">                System.err.println();<br /></span><span style="COLOR: #008080">107</span> <span style="COLOR: #000000">                System.err.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">There were </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> parseErrors.size()<br /></span><span style="COLOR: #008080">108</span> <span style="COLOR: #000000">                        </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> errors</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">109</span> <span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">110</span> <span style="COLOR: #000000">                Iterator i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> parseErrors.iterator();<br /></span><span style="COLOR: #008080">111</span> <span style="COLOR: #000000">                </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (i.hasNext()) {<br /></span><span style="COLOR: #008080">112</span> <span style="COLOR: #000000">                    System.err.println(i.next());<br /></span><span style="COLOR: #008080">113</span> <span style="COLOR: #000000">                }<br /></span><span style="COLOR: #008080">114</span> <span style="COLOR: #000000">            }<br /></span><span style="COLOR: #008080">115</span> <span style="COLOR: #000000">        } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (UnsupportedEncodingException e) {<br /></span><span style="COLOR: #008080">116</span> <span style="COLOR: #000000">            System.err.println(e.toString());<br /></span><span style="COLOR: #008080">117</span> <span style="COLOR: #000000">        }<br /></span><span style="COLOR: #008080">118</span> <span style="COLOR: #000000">    }<br /></span><span style="COLOR: #008080">119</span> <span style="COLOR: #000000">}</span></div><br /><br /><br />两篇中文的介l:<br /><a >http://www.chinaitpower.com/A/2005-03-03/109739.html</a><br /><a >http://www.myfaq.com.cn/A200507/2005-07-24/166992.html</a><a ></a><img src ="http://www.aygfsteel.com/terry-zj/aggbug/47643.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/terry-zj/" target="_blank">Terry的Blog</a> 2006-05-23 14:47 <a href="http://www.aygfsteel.com/terry-zj/archive/2006/05/23/47643.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>日文~码与Unicode~码转换Q未完)http://www.aygfsteel.com/terry-zj/archive/2006/04/20/42201.htmlTerry的BlogTerry的BlogThu, 20 Apr 2006 09:45:00 GMThttp://www.aygfsteel.com/terry-zj/archive/2006/04/20/42201.htmlhttp://www.aygfsteel.com/terry-zj/comments/42201.htmlhttp://www.aygfsteel.com/terry-zj/archive/2006/04/20/42201.html#Feedback3http://www.aygfsteel.com/terry-zj/comments/commentRss/42201.htmlhttp://www.aygfsteel.com/terry-zj/services/trackbacks/42201.html参考网址Q?br />日本語のUnicodeベンダ依存文字?http://www.ingrid.org/java/i18n/unicode.html



Terry的Blog 2006-04-20 17:45 发表评论
]]>
日文字符中常见的q情况---正L线“~?/title><link>http://www.aygfsteel.com/terry-zj/archive/2006/04/20/42108.html</link><dc:creator>Terry的Blog</dc:creator><author>Terry的Blog</author><pubDate>Thu, 20 Apr 2006 02:46:00 GMT</pubDate><guid>http://www.aygfsteel.com/terry-zj/archive/2006/04/20/42108.html</guid><wfw:comment>http://www.aygfsteel.com/terry-zj/comments/42108.html</wfw:comment><comments>http://www.aygfsteel.com/terry-zj/archive/2006/04/20/42108.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/terry-zj/comments/commentRss/42108.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/terry-zj/services/trackbacks/42108.html</trackback:ping><description><![CDATA[ <p>在一般的日文字符表示正常的情况下正L线“~”Q然经怼出现q的情c?br /><br />数据库参数NLS Database Parameters<br />NLS_CHARACTERSET                   JA16SJIS <br />NLS_NCHAR_CHARACTERSET   AL16UTF16<br /><br />一Q对于VARCHAR2字段<br />现象Q在面上输入“~”存入DB后再取出到页面时变成??strong>Q页面的字符讄为charset=shift-jisQ?/strong><br />调查Q?br />1 面提交后在java中观察编码ؓ\uff5e<br />2 java中定义一个字W变量“~”观察编码ؓ\uff5e<br />3 ~码为\uff5e的字W存入数据库再取出的~码为\u301c<br />4 用Object Browser观察数据库中字符都正?br />l论Q存入数据库时编码发生了变化\uff5e ---> \u301c<br />解决Q取出数据时遍历发现\u301cp{换ؓ\uff5e<br />      public String getString(int columnIndex) throws SQLException {<br />         // TODO: ~を変更<br />         String value = rs.getString(columnIndex);<br />         if (value != null){<br />              StringBuffer sbDest = new StringBuffer();<br />              char ch;<br />              for(int j= 0;j< value.length();j++){<br />                  ch = value.charAt(j);<br />                  if(ch == 0x301c){<br />                      sbDest.append("\uff5e"); // ?br />                  }else{<br />                      sbDest.append(ch);<br />                  }<br />              }<br />              value = sbDest.toString();<br />         }</p> <p>         return value;<br />     }<br /><br />二:对于NVARCHAR2字段<br />现象Q在面上输入正波浪U쀜~”存入DB后再取出到页面时变成反L线“〜?strong>Q页面的字符讄为charset=UTF-8Q?br /></strong>用Object Browser工具察看表中的数?发现是正波浪U쀜~?~码为\u301c。(实际上用Object Browser看\u301c  \uff5e都是正L线Q?br />如果用NVARCHAR2字段Q那么正的操作后可以存入\uff5e<br /><br />试验用表 Products Q表中的列定义如下所C?br />id - VARCHAR2(10) ?产品 id<br />lang_id ?VARCHAR2(10) ?语言 id<br />description ?NVARCHAR2(2000) ?Unicode ~码的品描q?br /><br />JDBC 允许 Java E序讉K Oracle9i 数据库中?NVARCHAR2 数据cd的列。Oracle JDBC 驱动E序?SQL NCHAR/NVARCHAR2 列中的数据从本地字符集编码(UTF8 ?AL16UTF16Q直接{化ؓ UTF-16 ~码?Java 字符丌Ӏ?br />为此Q我们需要把 Java 字符串绑定到一?NVARCHAR2 列。下面的代码D|CZ完成q项d的代码?/p> <p>// Get an Oracle preparedstatement<br />OraclePreparedStatement orastmt =(OraclePreparedStatement)connection.prepareStatement(<br />"INSERT INTO PRODUCTS VALUES(?,?,?)");<br />// Bind the 3rd parameter to NVARCHAR2 form so that the data is stored as unicode<br /><strong>orastmt.setFormOfUse(3,OraclePreparedStatement.FORM_NCHAR);<br /></strong>orastmt.setString(1,product.getId());<br />orastmt.setString(2,product.getLangId());<br />orastmt.setString(3,product.getDescription());<br />orastmt.executeUpdate();<br />orastmt.close();</p> <p>使用 orastmt.setFormOfUse() Ҏ来指定列的类型是 NVARCHAR2。确保数据以Unicode ~码存储?br /><br />关于NVARCHAR2字段的操作参考:<br /><a >http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/9i_jdbc/NCHARsupport4UnicodeSample/Readme.html</a><br /><br />注意q段话:<br />The only difference in usage between the SQL CHAR and SQL NCHAR datatypes occur in a data bind situation. <br />The JDBC program must call the setFormOfUse() method to specify if the data is bound for a SQL NCHAR<br />datatype and <strong>it must be called before binding</strong> Java variables to SQL NCHAR datatypes.<br /><strong>必须先setFormOfUse再绑定变量。否则存入数据库中的仍是\u301c<br /></strong></p> <img src ="http://www.aygfsteel.com/terry-zj/aggbug/42108.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/terry-zj/" target="_blank">Terry的Blog</a> 2006-04-20 10:46 <a href="http://www.aygfsteel.com/terry-zj/archive/2006/04/20/42108.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>比较Oracle SQL中的IN & EXISTShttp://www.aygfsteel.com/terry-zj/archive/2006/04/18/41662.htmlTerry的BlogTerry的BlogTue, 18 Apr 2006 08:01:00 GMThttp://www.aygfsteel.com/terry-zj/archive/2006/04/18/41662.htmlhttp://www.aygfsteel.com/terry-zj/comments/41662.htmlhttp://www.aygfsteel.com/terry-zj/archive/2006/04/18/41662.html#Feedback5http://www.aygfsteel.com/terry-zj/comments/commentRss/41662.htmlhttp://www.aygfsteel.com/terry-zj/services/trackbacks/41662.html在Oracle SQL中取数据时有时要用到in ?exists 那么他们有什么区别呢Q?br />
1 性能上的比较
比如Select * from T1 where x in ( select y from T2 )
执行的过E相当于:
select *
  from t1, ( select distinct y from t2 ) t2
 where t1.x = t2.y;

相对?/p>

select * from t1 where exists ( select null from t2 where y = x )
执行的过E相当于:
for x in ( select * from t1 )
   loop
      if ( exists ( select null from t2 where y = x.x )
      then
         OUTPUT THE RECORD
      end if
end loop
表 T1 不可避免的要被完全扫描一?/p>

分别适用在什么情?
以子查询 ( select y from T2 )虑方向
如果子查询的l果集很大需要消耗很多时_但是T1比较执? select null from t2 where y = x.x )非常快,那么exists比较适合用在q里
相对应得子查询的l果集比较小的时候就应该使用in.

2 含义上的比较
在标准的scott/tiger用户?br />

    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
1 7499 ALLEN SALESMAN 7698 1981/02/20 1600.00 300.00 30
2 7521 WARD SALESMAN 7698 1981/02/22 1250.00 500.00 30
3 7566 JONES MANAGER 7839 1981/04/02 2975.00 20
4 7654 MARTIN SALESMAN 7698 1981/09/28 1250.00 1400.00 30
5 7698 BLAKE MANAGER 7839 1981/05/01 2850.00 30
6 7782 CLARK MANAGER 7839 1981/06/09 2450.00 10
7 7788 SCOTT ANALYST 7566 1987/04/19 3000.00 20
8 7839 KING PRESIDENT   1981/11/17 5000.00 10
9 7844 TURNER SALESMAN 7698 1981/09/08 1500.00 0.00 30
10 7876 ADAMS CLERK 7788 1987/05/23 1100.00 20
11 7900 JAMES CLERK 7698 1981/12/03 950.00 30
12 7902 FORD ANALYST 7566 1981/12/03 3000.00 20
13 7934 MILLER CLERK 7782 1982/01/23 1300.00   10

执行
SQL> select count(*) from emp where empno not in ( select mgr from emp );
COUNT(*)
----------
         0
SQL> select count(*) from emp T1
  2  where not exists ( select null from emp T2 where t2.mgr = t1.empno ); -- q里子查询中取出nullq没有什么特D作用,只是表示取什么都一栗?br />COUNT(*)
----------
         8
l果明显不同Q问题就出在MGR=null的那条数据上。Q何值X not in (null)  l果都不成立?br />用一个小例子试验一?
select * from dual where dummy not in ( NULL ) -- no rows selected
select * from dual where NOT( dummy not in ( NULL ) ) --no rows selected
知觉上这两句SQLL一句会取出数据的,但是实际上都没有。SQL中逻辑表达式的值可以有三种l果Qtrue false nullQ而null相当于false.




Terry的Blog 2006-04-18 16:01 发表评论
]]>
վ֩ģ壺 ²| | | Ǩ| | ɽ| ؿ˹| | ߱| | | Ǭ| ɽ| ɽ| | ʳ| ٰ| | Ѿ| Ľ| »| ֿ| | | | | ʡ| ̶| ʳ| | | | | | | ƾ| | ˹| | | Ͼ|