??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲黄色在线电影,亚洲最大中文字幕无码网站 ,爱情岛亚洲论坛在线观看http://www.tkk7.com/jspark/星星之火、可以燎?/description>zh-cnFri, 09 May 2025 23:56:54 GMTFri, 09 May 2025 23:56:54 GMT60如何更方便地q行CSV格式文gdhttp://www.tkk7.com/jspark/archive/2008/10/31/237819.htmljsparkjsparkFri, 31 Oct 2008 06:42:00 GMThttp://www.tkk7.com/jspark/archive/2008/10/31/237819.htmlhttp://www.tkk7.com/jspark/comments/237819.htmlhttp://www.tkk7.com/jspark/archive/2008/10/31/237819.html#Feedback3http://www.tkk7.com/jspark/comments/commentRss/237819.htmlhttp://www.tkk7.com/jspark/services/trackbacks/237819.html 

1      基本介绍

可以?/span>CSV格式的文件经常碰刎ͼ何ؓCSV格式Q?/span>CVS全称comma-separated valuesQ就是典型的用逗号隔开的文Ӟ比如下面q种文g格式

Name,company

zhangsan,ibm

lisi,oracle

q种是典型?/span>CSV格式文g。不q也可以扩展到其它符号隔开的字W,比如

Name#company

Zhangsan#ibm

Lisi#oracle

q种也算CSV格式

Java开源框?/span>CVSReader提供了一个轻量、简单方便的l一操作接口可用Q下面具体讲解如何操?/span>CVS格式

2      安装和?/span>

2.1下蝲

目前CSV reader的最新发布版本是1.8。我们可以从

http://opencsv.sourceforge.net/

上面下蝲到最新的csvreader包?/span>

2.2安装

直接?/span>jar包分别存攑ֈ开发工E的c\径下面即可用?/span>

3      dCSV格式文g

3.1基本?/span>

首先Q读?/span>CSV格式的文仉要创Z?/span>CSVReaderQ如?/span>

CsvReader reader = new CsvReader(Reader r,  char c);

其中W一个参Cؓd文gQ第二个参数为分割符Q比?#8220;,”Q或?#8220;#

另外Q也有其它几个参敎ͼ可以查阅APIQ比?/span>

CsvReader reader = new CsvReader(InputStream r,  char c, Charset charset);{等

其次Q一般需要读取头信息Q如下:

reader.readHeaders();

String[] headers = reader.getHeaders();

d了后Q指针就会移动到下一行,也就是可以开始读取文件内?/span>

假如Q有多行的话Q可以用一个@环套入,例如下面Q?/span>

             while (reader.readRecord()) {

                    for (int i = 0; i < headers.length; i++) {

                           String value = reader.get(headers[i]);

                           System.out.print(value+" ");

                    }

                    System.out.println("");

             }

3.2l合例子

?/span>C盘下创徏一个测试文?/span>test.cvsQ内容如下:

a#b#c

1#2#3

4#5#6

下面是解析代码:

      public static void main(String[] args) throws Exception {

CsvReader reader = new CsvReader(new FileReader("c://csv.txt"), '#');

             reader.readHeaders();

             String[] headers = reader.getHeaders();

             while (reader.readRecord()) {

                    for (int i = 0; i < headers.length; i++) {

                           String value = reader.get(headers[i]);

                           System.out.print(value+" ");

                    }

                    System.out.println("");

             }

      }

q行以上E序Q可以看到输?/span>

 1 2 3

 4 5 6

4      ?/span>CSV格式文g

?/span>CSV格式文g也比较简单,写每一列只要直接调?/span>

csvWriter.write()卛_

另外Q写完每行结束后Q都要调?/span> csvWriter.endRecord();

表示l束一?/span>

文g写完毕后Q要记得h一下ƈxQ如下:

       csvWriter.flush();

       csvWriter.close();

代码如下Q?/span>

    publicstaticvoid main(String[] args) throws Exception {

       CsvWriter csvWriter = new CsvWriter(new FileWriter("c://test.text"), '#');

       csvWriter.write("name");

       csvWriter.write("company");

       csvWriter.endRecord();

       csvWriter.write("11");

       csvWriter.write("12");

       csvWriter.endRecord();

       csvWriter.write("21");

       csvWriter.write("22");

       csvWriter.flush();

       csvWriter.close();

   }

}

q行以上E序Q可以看?/span>C盘下面创Z一个文?/span>

test.text

内容如下Q?/span>

name#company

11#12

21#22



jspark 2008-10-31 14:42 发表评论
]]>
JbossRules入门Q二Q?/title><link>http://www.tkk7.com/jspark/archive/2008/10/28/237135.html</link><dc:creator>jspark</dc:creator><author>jspark</author><pubDate>Tue, 28 Oct 2008 07:54:00 GMT</pubDate><guid>http://www.tkk7.com/jspark/archive/2008/10/28/237135.html</guid><wfw:comment>http://www.tkk7.com/jspark/comments/237135.html</wfw:comment><comments>http://www.tkk7.com/jspark/archive/2008/10/28/237135.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jspark/comments/commentRss/237135.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jspark/services/trackbacks/237135.html</trackback:ping><description><![CDATA[     摘要: Q本文档的全可以到博客下面的文件列表下载,地址下面Q?nbsp; http://www.tkk7.com/jspark/admin/Files.aspx Z让尽快对jbossRules有一个感官的认识Q下面先开发一个HelloWorld的程序?建立一个java工程Q目录如下:     如上所C,建立一个com包,然后在下面分别徏立一个Sa...  <a href='http://www.tkk7.com/jspark/archive/2008/10/28/237135.html'>阅读全文</a><img src ="http://www.tkk7.com/jspark/aggbug/237135.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jspark/" target="_blank">jspark</a> 2008-10-28 15:54 <a href="http://www.tkk7.com/jspark/archive/2008/10/28/237135.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JbossRules入门Q一Q?/title><link>http://www.tkk7.com/jspark/archive/2008/10/28/237071.html</link><dc:creator>jspark</dc:creator><author>jspark</author><pubDate>Tue, 28 Oct 2008 04:15:00 GMT</pubDate><guid>http://www.tkk7.com/jspark/archive/2008/10/28/237071.html</guid><wfw:comment>http://www.tkk7.com/jspark/comments/237071.html</wfw:comment><comments>http://www.tkk7.com/jspark/archive/2008/10/28/237071.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/jspark/comments/commentRss/237071.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jspark/services/trackbacks/237071.html</trackback:ping><description><![CDATA[  <h1>1<span style="font: 7pt 'Times New Roman'">      </span>Java<span style="font-family: 仿宋_GB2312">规则pȝ?/span></h1> <p><span style="font-family: 仿宋_GB2312">在大型商业系l中Q业务规则、商业逻辑{等都会比较复杂。而且在很多大型系l当中,很多业务规则、商业逻辑q不是一成不变的。甚臛_pȝq入生阶段Ӟ客户的业务规则、商业逻辑也会改变。某些系l要求甚x高,要求?/span>24<span style="font-family: 仿宋_GB2312">时不停机,q且能够实时修改商业规则。这对商业pȝ提出了较大的挑战。如果将q些可变的规则直接编写到代码里面的话Q业务规则一旦改变,p修改代码。ƈ由此带来~译、打包、发布等{问题。这对于生pȝ来说是极不方便的。因此,如何考虑把一些可变的业务规则抽取到外面,使这些业务规则独立于E序代码。ƈ最好是能够实时的修改业务规则,q样可以做C用打包编译发布等{?/span></p> <p><span style="font-family: 仿宋_GB2312">值得庆幸的是现在出现了一?/span>Java<span style="font-family: 仿宋_GB2312">规则引擎Q?/span>Rule Engine<span style="font-family: 仿宋_GB2312">Q,专门解决以上所q的问题。利用它Q我们就可以在应用系l中分离客户的商业决{逻辑和应用开发者的技术决{,q把q些商业规额则放在中心数据库或其他统一的地方,让它们能在运行时可以动态地理和修攏V?/span></p> <p>JbossRules<span style="font-family: 仿宋_GB2312">是一个优U?/span>JAVA<span style="font-family: 仿宋_GB2312">规则引擎Q其前n?/span>Drools3<span style="font-family: 仿宋_GB2312">Q后来被</span>Jboss<span style="font-family: 仿宋_GB2312">合ƈq改名ؓ</span>JbossRules</p> <h2><span style="font-family: 宋体">1.1</span><span style="font-family: 仿宋_GB2312">Z规则的专家系l简?/span></h2> <p><span style="font-family: 仿宋_GB2312">人工是一个新兴的学科Q它是想让计机模拟的思维和推理模式。h工智能分成如下几个主要的分学U:</span></p> <p><span style="font-family: 仿宋_GB2312">知识表示</span></p> <p><span style="font-family: 仿宋_GB2312">经|络</span></p> <p><span style="font-family: 仿宋_GB2312">基因法</span></p> <p><span style="font-family: 仿宋_GB2312">决策?/span></p> <p><span style="font-family: 仿宋_GB2312">专家pȝ</span></p> <p><span style="font-family: 仿宋_GB2312">{等几个学科</span></p> <p><span style="font-family: 仿宋_GB2312">知识表示是h工智能中的一个基领域Q其目的是如何更好的在计机当中描述已存在的事实。专家系l就是用知识表C,来做规则推理Q得出最后的l论来?/span></p> <p>Java<span style="font-family: 仿宋_GB2312">规则引擎h于基于规则的专家pȝQ而基于规则的专家pȝ又是专家pȝ的其中一个分支。专家系l属于h工智能的范畴Q它模仿人类的推理方式,使用试探性的Ҏq行推理Qƈ使用人类能理解的术语解释和证明它的推理结论。ؓ了更深入C?/span>Java<span style="font-family: 仿宋_GB2312">规则引擎Q下面简要地介绍Z规则的专家系l?/span>RBES<span style="font-family: 仿宋_GB2312">包括三部分:</span>Rule Base<span style="font-family: 仿宋_GB2312">Q?/span>knowledge base<span style="font-family: 仿宋_GB2312">Q?/span>Working Memory<span style="font-family: 仿宋_GB2312">Q?/span>fact base<span style="font-family: 仿宋_GB2312">Q和</span>Inference Engine<span style="font-family: 仿宋_GB2312">。它们的l构如下pȝ所C:</span></p> <p><span style="font-family: 仿宋_GB2312">如上图所C,推理引擎包括三部分:模式匚w器(</span>Pattern Matcher<span style="font-family: 仿宋_GB2312">Q、议E(</span>Agenda<span style="font-family: 仿宋_GB2312">Q和执行引擎Q?/span>Execution Engine<span style="font-family: 仿宋_GB2312">Q。推理引擎通过军_哪些规则满事实或目标,q授予规则优先Q满事实或目标的规则被加入议程。模式匹配器军_选择执行哪个规则Q何时执行规则;议程理模式匚w器挑选出来的规则的执行次序;执行引擎负责执行规则和其他动作?/span></p> <p style="text-indent: 19.85pt"><span style="font-family: 仿宋_GB2312">和hcȝ思维相对应,推理引擎存在两者推理方式:演绎法(</span>Forward-Chaining<span style="font-family: 仿宋_GB2312">Q和归纳法(</span>Backward-Chaining<span style="font-family: 仿宋_GB2312">Q。演l法从一个初始的事实出发Q不断地应用规则得出l论Q或执行指定的动作)。而归Ux则是Ҏ假设Q不断地LW合假设的事实?/span>Rete<span style="font-family: 仿宋_GB2312">法是目前效率最高的一?/span>Forward-Chaining<span style="font-family: 仿宋_GB2312">推理法Q许?/span>Java<span style="font-family: 仿宋_GB2312">规则引擎都是Z</span>Rete<span style="font-family: 仿宋_GB2312">法来进行推理计的?/span></p> <p style="margin-left: 60.75pt; text-indent: -21pt"><span style="font-family: Wingdings">l </span><strong><span style="font-family: 仿宋_GB2312">正向推理Q?/span></strong></p> <p style="margin-left: 60.75pt; text-indent: 0cm"><strong> </strong></p> <p style="margin-left: 15.6pt"><span style="font-family: 仿宋_GB2312">正向推理囑Ş如下Q?/span></p> <p style="margin-left: 19.85pt; text-indent: 19.85pt"><span style="font-family: 仿宋_GB2312">正向推理引擎的推理步骤如下:</span></p> <p style="margin-left: 63pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">初始数据(</span>fact<span style="font-family: 仿宋_GB2312">Q输?/span>Working Memory<span style="font-family: 仿宋_GB2312">?/span></p> <p style="margin-left: 63pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">使用</span>Pattern Matcher<span style="font-family: 仿宋_GB2312">比较规则库(</span>rule base<span style="font-family: 仿宋_GB2312">Q中的规则(</span>rule<span style="font-family: 仿宋_GB2312">Q和数据Q?/span>fact<span style="font-family: 仿宋_GB2312">Q?/span></p> <p style="margin-left: 63pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">如果执行规则存在冲突Q?/span>conflict<span style="font-family: 仿宋_GB2312">Q,卛_时激zM多个规则Q将冲突的规则放入冲H集合?/span></p> <p style="margin-left: 63pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">解决冲突Q将Ȁzȝ规则按顺序放?/span>Agenda<span style="font-family: 仿宋_GB2312">?/span></p> <p style="margin-left: 63pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">使用执行引擎执行</span>Agenda<span style="font-family: 仿宋_GB2312">中的规则。重复步?/span>2<span style="font-family: 仿宋_GB2312">?/span>5<span style="font-family: 仿宋_GB2312">Q直到执行完毕所?/span>Agenda<span style="font-family: 仿宋_GB2312">中的规则?/span></p> <p style="margin-left: 63pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">直到得出最l的l果为止</span></p> <p style="margin-left: 60.75pt; text-indent: -21pt"><span style="font-family: Wingdings">l </span><strong><span style="font-family: 仿宋_GB2312">反向推理Q?/span></strong></p> <p style="margin-left: 60.75pt; text-indent: 0cm"><strong> </strong></p> <p style="margin-left: 60.75pt; text-indent: 0cm"><span style="font-family: 仿宋_GB2312">反向推理是目标驱动的推理方式。从目标出发Q找出所有能满该目</span></p> <p><span style="font-family: 仿宋_GB2312">标的子目标。这样一直推g去,直到所有的子目标都已经满为止?/span></p> <h2><span style="font-family: 宋体">1.2</span>Java<span style="font-family: 仿宋_GB2312">规则引擎</span></h2> <p>Java<span style="font-family: 仿宋_GB2312">规则引擎是一U嵌入在</span>Java<span style="font-family: 仿宋_GB2312">E序中的lgQ它的Q务是把当前提交给引擎?/span>Java<span style="font-family: 仿宋_GB2312">数据对象与加载在引擎中的业务规则q行试和比对,Ȁz那些符合当前数据状态下的业务规则,Ҏ业务规则中声明的执行逻辑Q触发应用程序中对应的操作?/span></p> <p><span style="font-family: 仿宋_GB2312">一般来_一条规则的形式如下Q?/span></p> <p>when</p> <p>    <conditions></p> <p>then</p> <p>    <actions></p> <p><span style="font-family: 仿宋_GB2312">也就是说Q当</span>conditions<span style="font-family: 仿宋_GB2312">成立的话Q就做下面的</span>actions<span style="font-family: 仿宋_GB2312">。其?/span>actions<span style="font-family: 仿宋_GB2312">可以为生成新的事实、或者做其他动作Q比如,发?/span>email<span style="font-family: 仿宋_GB2312">通知、执行一些本CQ务等{?/span></p> <h2>1.3<span style="font: 7pt 'Times New Roman'">    </span>JAVA<span style="font-family: 仿宋_GB2312">规则引擎的优?/span></h2> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">声明式编E?/span></p> <p style="margin-left: 45.1pt; text-indent: 0cm"><span style="font-family: 仿宋_GB2312">声明式编E,规则引擎让我们直?#8220;做什?#8221;Q而不用直?#8220;怎么?#8221;。我们只要把一pd规则表示出来后。具体的推理动作׃l规则引擎来处理?/span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">逻辑和数据分开</span></p> <p style="margin-left: 45.1pt; text-indent: 0cm"><span style="font-family: 仿宋_GB2312">可变的业务逻辑和数据分开。虽Ӟq违背了面向对象原则。面向对象强调数据和业务逻辑耦合。但是,对于一些易变而复杂的业务规则。如果散步在E序的各个地斏V各个层ơ。那么一旦业务规则更改的话,׃出现“牵一发而动全n”的局面。因此,可变的业务逻辑独立出来理Q将有助于后面的业务变更?/span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">性能</span></p> <p style="margin-left: 45.1pt; text-indent: 0cm">Rete<span style="font-family: 仿宋_GB2312">法的性能比较高?/span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">知识集中表示</span></p> <p style="margin-left: 59.55pt; text-indent: 0cm"><span style="font-family: 仿宋_GB2312">通过使用规则Q我们把规则集中存放hQ从而ɾpȝ知识能够集中表示?/span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">可读?/span></p> <p style="margin-left: 59.55pt; text-indent: 0cm"><span style="font-family: 仿宋_GB2312">规则的可L比较高。对于熟悉业务规则。但不会E序开发的业务专家Q只要熟悉规则的标示Q也可以~写和修改业务规则?/span></p> <h2>1.4<span style="font: 7pt 'Times New Roman'">    </span><span style="font-family: 仿宋_GB2312">使用</span>JAVA<span style="font-family: 仿宋_GB2312">规则pȝ的场?/span></h2> <p><span style="font-family: 仿宋_GB2312">那么Q在那些场合下适合应用</span>JAVA<span style="font-family: 仿宋_GB2312">规则pȝ呢?总而言之,可以用一句话来概括:当用传统的程序开发,无法得到一U优雅的解决Ҏ的时候,可以考虑使用规则pȝ。如下的一些场合:</span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">用传l的代码开发比较复杂、繁?/span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">问题虽然不复杂,但是用传l的代码开发比较脆弱,也就是经怿?/span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">没有优雅的算?/span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">业务规则频繁改变</span></p> <p style="margin-left: 45.1pt; text-indent: -21pt"><span style="font-family: Wingdings">n </span><span style="font-family: 仿宋_GB2312">有很多业务专家、不懂技术开?/span></p> <h2>1.5<span style="font: 7pt 'Times New Roman'">    </span><span style="font-family: 仿宋_GB2312">不适合使用</span>JAVA<span style="font-family: 仿宋_GB2312">规则pȝ场合</span></h2> <p><span style="font-family: 仿宋_GB2312">虽然规则pȝ看v来比较不错,但是q不是Q何地斚w可以使用规则pȝ。很多简单、固定的业务pȝQ可以不用用规则系l。规则系l也不能用来作ؓ标示重要的业务流E、不能用来作为工作流引擎?/span></p> <p><span style="font-family: 仿宋_GB2312">有很多程序员?/span>JAVA<span style="font-family: 仿宋_GB2312">规则pȝ当成是一U动态修攚w|。也是把一部分代码逻辑抽取到外面,l一存放h。这P当一些配|修改的话,通过修改规则Q就能修改代码的一部分逻辑。如果把</span>JAVA<span style="font-family: 仿宋_GB2312">规则仅仅用在q个场合下的话,可以考虑采用脚本引擎。比?/span>BeanShell<span style="font-family: 仿宋_GB2312">?/span>JEXL<span style="font-family: 仿宋_GB2312">?/span>Groovy<span style="font-family: 仿宋_GB2312">{等?/span></p> <img src ="http://www.tkk7.com/jspark/aggbug/237071.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jspark/" target="_blank">jspark</a> 2008-10-28 12:15 <a href="http://www.tkk7.com/jspark/archive/2008/10/28/237071.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>安装SUN ONE APPSERVER8.1以及部v应用所到的问?/title><link>http://www.tkk7.com/jspark/archive/2006/11/29/84348.html</link><dc:creator>jspark</dc:creator><author>jspark</author><pubDate>Wed, 29 Nov 2006 06:42:00 GMT</pubDate><guid>http://www.tkk7.com/jspark/archive/2006/11/29/84348.html</guid><wfw:comment>http://www.tkk7.com/jspark/comments/84348.html</wfw:comment><comments>http://www.tkk7.com/jspark/archive/2006/11/29/84348.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/jspark/comments/commentRss/84348.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jspark/services/trackbacks/84348.html</trackback:ping><description><![CDATA[<p><font size=2></p> <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: #000000">grant {<br>    permission java.lang.RuntimePermission  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">loadLibrary.*</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>    permission java.lang.RuntimePermission  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">queuePrintJob</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>    permission java.lang.RuntimePermission  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">setContextClassLoader</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>    permission java.lang.RuntimePermission  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">getProtectionDomain</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>    permission java.lang.reflect.ReflectPermission </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">suppressAccessChecks</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>    };<br><br>grant {<br>    permission java.util.PropertyPermission   </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"> read,write </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> ;<br><br>};  <br></span></div> <p>     最q一个项目需要用到SUN ONE APPSERVER8.1Q本人在WINDOWS SERVER 2003中安装,到一些问题,不过比较q运的是都解决了Q下面大概描qC下个人碰到的问题Q期望能l别人带来帮?/font> </p> <p><font size=2>   一、DNS服务器问?br>    安装SUN ONE APPSERVER8.1必须要在服务器上安装Q而且必须要将该服务器讄为DNS服务器。关于WINDOWS SERVER 2003<br>    如何讄DNS服务器,|上很多资料Q可以查?br></font><font size=2><br>   二、文件系l权限访问问?br> 也许SUN ONE APPSERVER8.1服务器在文g讉K斚w控制比较严格Q如果按照默认安装上ȝpȝ。对于一些文件夹、文件读取是会有一些控制的。比如说Q当应用部|上去,然后讉K应用Q会抛出SecurityException。这是因为需要编译jsp面Q生成class文gQ由于没有写权限Q所以会出错。解决的Ҏ是ؓSUN ONE APPSERVER增加文g讉K权限。修Ҏ法如下:<br> 扑ֈ安装路径Q下面以本h的安装\径ؓ例子Q?br> c\sunjes\ApplicationServer\domains\domain1\config<br> 该目录下面有一个文件叫server.policyQ打开该页面,可以看到里面是一些关于文件访问权限的例子<br></font></p> <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"><font size=2><span style="COLOR: #000000">    <img src="http://www.tkk7.com/Images/dot.gif"><br></span><span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> Core server classes get all permissions by default</span> </font><span style="COLOR: #008000"><br></span><font size=2><span style="COLOR: #000000">grant codeBase </span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">file:${com.sun.aas.installRoot}/lib/-</span> <span style="COLOR: #000000">"</span> </font><font size=2><span style="COLOR: #000000"> {<br>    permission java.security.AllPermission;<br>};<br>    <img src="http://www.tkk7.com/Images/dot.gif"><br>    下面为文件\径增加访问权限,个h把整个c盘设|ؓ可读可写Q如?br><br>    grant codeBase </span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">file:c:/-</span> <span style="COLOR: #000000">"</span> </font><font size=2><span style="COLOR: #000000"> {<br>    permission java.security.AllPermission;<br>};<br><br>grant {<br>    permission java.io.FilePermission </span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">c:/-</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">, </span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">read,write,execute,delete</span> <span style="COLOR: #000000">"</span> </font><span style="COLOR: #000000"><font size=2>;<br><br>}; </font> </span></div> <p><br><font size=2> ~辑完毕Q保存,重启服务器,OKQ该问题解决?:)</font> <br></p> <p><font size=2>  三、其他几个权限问题:<br>         ~辑以上问题后,重新自动Q可能还会发C下几个异常,比如 permission java.util.PropertyPermission   "*" ,  " read,write " ;<br>      因此Q分别加上如下几个权限设|即?br>    </p> <p><br><br>  四、ORACLE10.2.0.1驱动问题<br> 本h部v的应用是spring+hb架构Q里面用到blog/clob大字D处理,因此驱动E序用最新的驱动E序10gQ版本ؓ10.2.0.1。在部v到SUN ONE APPSERVER8.1Ӟ也抛出类讉K异常Q异怿息是Qoracle.sql is sealed。没办法Q上|搜索了一下,发现有很多h也遇q这个情c主要是oracle10g.jar里面的Meta-inf定义Q增加了sealed属性。打开该文件MANIFEST.MFQ内容如下:<br> </font> </p> <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"><font size=2><span style="COLOR: #000000">    Manifest</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">Version: </span> <span style="COLOR: #000000">1.0</span> </font><span style="COLOR: #000000"><br><font size=2>Specification</font> </span><font size=2><span style="COLOR: #000000">-</span> <span style="COLOR: #000000">Title:    Oracle JDBC driver classes </span> <span style="COLOR: #0000ff">for</span> </font><font size=2><span style="COLOR: #000000"> use with JDK14<br>Created</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">By: </span> <span style="COLOR: #000000">1.4</span> </font><font size=2><span style="COLOR: #000000">.2_08 (Sun Microsystems Inc.)<br>sealed:</span> <span style="COLOR: #0000ff">true</span> </font><span style="COLOR: #000000"><br><font size=2>Implementation</font> </span><span style="COLOR: #000000"><font size=2>-</font> </span><font size=2><span style="COLOR: #000000">Title:   ojdbc14.jar<br>Specification</span> <span style="COLOR: #000000">-</span> </font><font size=2><span style="COLOR: #000000">Vendor:   Oracle Corporation<br>Specification</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">Version:  Oracle JDBC Driver version </span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">10.2.0.1.0</span> <span style="COLOR: #000000">"</span> </font><span style="COLOR: #000000"><br><font size=2>Implementation</font> </span><font size=2><span style="COLOR: #000000">-</span> <span style="COLOR: #000000">Version: Oracle JDBC Driver version </span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">10.2.0.1.0</span> <span style="COLOR: #000000">"</span> </font><span style="COLOR: #000000"><br><font size=2>Implementation</font> </span><span style="COLOR: #000000"><font size=2>-</font> </span><font size=2><span style="COLOR: #000000">Vendor:  Oracle Corporation<br>Implementation</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">Time:    Wed Jun </span> <span style="COLOR: #000000">22</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">18</span> <span style="COLOR: #000000">:</span> <span style="COLOR: #000000">55</span> <span style="COLOR: #000000">:</span> <span style="COLOR: #000000">48</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">2005</span> </font></div> <p><font size=2> 关于sealed属性网上也?br> 很多资料介绍Q有兴趣的网友可以参阅一下。网上同行的解决Ҏ是下?0gQ低点的版本。本人的解决Ҏ是修改一下里面的MANIFEST.MF文gQ把sealed:trueL卛_?/font> </p> <p><br><font size=2> 四、包版本不兼宏V?br> 解决完以上几个问题后Q重新启动,本以Z事大吉,很不q运的是Q再ơ抛出异常:<br> ClassNotFoundException: org.hibernate.hql.ast.HqlToken。同P上网搜烦了一下,发现是hibernate的antlr.jar和SUN ONE APPSERVER的antlr.jar存在冲突。hibernate3.0版本?br> 的antlr.jar包版本是2.7.5Q比SUN ONE APPSERVER的高。以前在weblogic部v应用Ӟ也出现过cM的问题。由于这些服务器会优先装载自qc,因此会出C些问题。解x法是把hibernate下较高版本的antlr.jar攑֜classpath的前面。在SUN ONE APPSERVER<br> 下最快捷的方式就是将antlr-2.7.5H3.jar拯到ApplicationServer\lib目录下面卛_</font> </p> <p><font size=2> 解决完以上几个问题后Q再ơ重启,讉KQOKQ一切正常!好有成就?:)</font> </p> <img src ="http://www.tkk7.com/jspark/aggbug/84348.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jspark/" target="_blank">jspark</a> 2006-11-29 14:42 <a href="http://www.tkk7.com/jspark/archive/2006/11/29/84348.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>(ZT)Sun HotSpot 1.4.1 JVM堆大的调整http://www.tkk7.com/jspark/archive/2006/11/28/84008.htmljsparkjsparkTue, 28 Nov 2006 03:58:00 GMThttp://www.tkk7.com/jspark/archive/2006/11/28/84008.htmlhttp://www.tkk7.com/jspark/comments/84008.htmlhttp://www.tkk7.com/jspark/archive/2006/11/28/84008.html#Feedback0http://www.tkk7.com/jspark/comments/commentRss/84008.htmlhttp://www.tkk7.com/jspark/services/trackbacks/84008.htmlSun HotSpot 1.4.1 JVM堆大的调整
    
    Sun HotSpot 1.4.1使用分代攉器,它把堆分Z个主要的域:新域、旧域以及永久域。Jvm生成的所有新对象攑֜新域中。一旦对象经历了一定数量的垃圾攉循环后,便获得用期q进入旧域。在怹域中jvm则存储class和method对象。就配置而言Q永久域是一个独立域q且不认为是堆的一部分?br />
    下面介绍如何控制q些域的大小。可使用-Xms?Xmx 控制整个堆的原始大小或最大倹{?br />    下面的命令是把初始大设|ؓ128MQ?br />    java –Xms128m
     –Xmx256m为控制新域的大小Q可使用-XX:NewRatio讄新域在堆中所占的比例?br />
   下面的命令把整个堆设|成128mQ新域比率设|成3Q即新域与旧域比例ؓ1Q?Q新域ؓ堆的1/4?2MQ?br />   java –Xms128m –Xmx128m
    –XX:NewRatio =3可?XX:NewSize?XX:MaxNewsize讄新域的初始值和最大倹{?br />
   下面的命令把新域的初始值和最大D|成64m:
     java –Xms256m –Xmx256m –Xmn64m
   怹域默认大ؓ4m。运行程序时Qjvm会调整永久域的大以满需要。每ơ调整时Qjvm会对堆进行一ơ完全的垃圾攉?br />
   使用-XX:MaxPerSize标志来增加永久域搭大。在WebLogic Server应用E序加蝲较多cLQ经帔R要增加永久域的最大倹{当jvm加蝲cLQ永久域中的对象急剧增加Q从而jvm不断调整怹域大。ؓ了避免调_可?XX:PerSize标志讄初始倹{?br />   下面把永久域初始D|成32mQ最大D|成64m?br />    java -Xms512m -Xmx512m -Xmn128m -XX:PermSize=32m -XX:MaxPermSize=64m

    默认状态下QHotSpot在新域中使用复制攉器。该域一般分Z个部分。第一部分为EdenQ用于生成新的对象。另两部分称为救助空_当Eden充满Ӟ攉器停止应用程序,把所有可到达对象复制到当前的from救助I间Q一旦当前的from救助I间充满Q收集器则把可到辑֯象复制到当前的to救助I间。From和to救助I间互换角色。维持活动的对象在救助I间不断复制Q直到它们获得用期q{入旧域。?XX:SurvivorRatio可控制新域子I间的大?br />
    同NewRation一PSurvivorRation规定某救助域与EdenI间的比倹{比如,以下命o把新域设|成64mQEden?2mQ每个救助域各占16mQ?br />    java -Xms256m -Xmx256m -Xmn64m -XX:SurvivorRation =2

    如前所qͼ默认状态下HotSpotҎ域用复制收集器Q对旧域使用标记Q清除-压羃攉器。在新域中用复制收集器有很多意义,因ؓ应用E序生成的大部分对象是短寿命的。理想状态下Q所有过渡对象在UdEdenI间时将被收集。如果能够这L话,q且UdEdenI间的对象是长寿命的Q那么理Z可以立即把它们移q旧域,避免在救助空间反复复制。但是,应用E序不能适合q种理想状态,因ؓ它们有一部分中长寿命的对象。最好是保持q些中长寿命的对象ƈ攑֜新域中,因ؓ复制部分的对象L压羃旧域廉h。ؓ控制新域中对象的复制Q可?XX:TargetSurvivorRatio控制救助I间的比例(该值是讄救助I间的用比例。如救助I间?MQ该?0表示可用500KQ。该值是一个百分比Q默认值是50。当较大的堆栈用较低的sruvivorratioӞ应增加该值到80?0Q以更好利用救助I间。用-XX:maxtenuring threshold可控制上限?br />
   为放|所有的复制全部发生以及希望对象从eden扩展到旧域,可以把MaxTenuring Threshold讄?。设|完成后Q实际上׃再用救助空间了Q因此应把SurvivorRatio设成最大g最大化EdenI间Q设|如下:
   java ?-XX:MaxTenuringThreshold=0 –XX:SurvivorRatioQ?0000 ?/span>


jspark 2006-11-28 11:58 发表评论
]]>
(ZT)Submit form into window.openerhttp://www.tkk7.com/jspark/archive/2006/11/22/82789.htmljsparkjsparkWed, 22 Nov 2006 07:39:00 GMThttp://www.tkk7.com/jspark/archive/2006/11/22/82789.htmlhttp://www.tkk7.com/jspark/comments/82789.htmlhttp://www.tkk7.com/jspark/archive/2006/11/22/82789.html#Feedback0http://www.tkk7.com/jspark/comments/commentRss/82789.htmlhttp://www.tkk7.com/jspark/services/trackbacks/82789.htmlAssigning the target property requires the name of a window not the window itself.

Wecould try something like

window.opener.name="opener728";
form.target="opener728";

however, I suspect the window.name property is read-only.

Alternatively, if We are certain that the opener already has a name then this might work

form.target=window.opener.name;

It's also possible that browsers assign unique names to otherwise unnamed windows, so the above would always work - I've never checked this.




jspark 2006-11-22 15:39 发表评论
]]>
csv reader的?/title><link>http://www.tkk7.com/jspark/archive/2006/11/07/79566.html</link><dc:creator>jspark</dc:creator><author>jspark</author><pubDate>Tue, 07 Nov 2006 04:05:00 GMT</pubDate><guid>http://www.tkk7.com/jspark/archive/2006/11/07/79566.html</guid><wfw:comment>http://www.tkk7.com/jspark/comments/79566.html</wfw:comment><comments>http://www.tkk7.com/jspark/archive/2006/11/07/79566.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jspark/comments/commentRss/79566.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jspark/services/trackbacks/79566.html</trackback:ping><description><![CDATA[ <p>今天从网上找了一个读写csv格式的开源程序,q挺好用的?br /><br />下面是一个读取例子:<br /><br />源文件格式:</p> <p> ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued<br /> 1,Chai,1,1,10 boxes x 20 bags,18,39,0,10,FALSE<br /> 2,Chang,1,1,24 - 12 oz bottles,19,17,40,25,FALSE<br /><br /> 下面dE序</p> <p> </p> <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"> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000"> CsvReader reader </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000"> CsvReader(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">products.csv</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> reader.readHeaders();<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">while</span> <span style="COLOR: #000000"> (reader.readRecord())<br /><img id="Codehighlighter1_106_649_Open_Image" onclick="this.style.display='none'; Codehighlighter1_106_649_Open_Text.style.display='none'; Codehighlighter1_106_649_Closed_Image.style.display='inline'; Codehighlighter1_106_649_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_106_649_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_106_649_Closed_Text.style.display='none'; Codehighlighter1_106_649_Open_Image.style.display='inline'; Codehighlighter1_106_649_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /> </span> <span id="Codehighlighter1_106_649_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_106_649_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String productID </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">ProductID</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String productName </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">ProductName</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String supplierID </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">SupplierID</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String categoryID </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">CategoryID</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String quantityPerUnit </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">QuantityPerUnit</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String unitPrice </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">UnitPrice</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String unitsInStock </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">UnitsInStock</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String unitsOnOrder </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">UnitsOnOrder</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String reorderLevel </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">ReorderLevel</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  String discontinued </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> reader.get(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">Discontinued</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  <br /><img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> perform program logic here</span> <span style="COLOR: #008000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> }</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> reader.close();<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> </div> <p> <br /> <br /> <br />写CSV例子Q?br /><br /> CsvWriter writer = new CsvWriter(new FileWriter(new File("c:\\1.csv")),',');<br />  writer.write("aa");<br />  writer.write("bb");<br />  writer.write("cc");<br />  writer.endRecord();<br />  writer.write("1");<br />  writer.write("2");<br />  writer.write("3");<br />  writer.close();<br /><br /></p> <img src ="http://www.tkk7.com/jspark/aggbug/79566.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jspark/" target="_blank">jspark</a> 2006-11-07 12:05 <a href="http://www.tkk7.com/jspark/archive/2006/11/07/79566.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>spring+hibernate的clob大字D处理(转蝲于javaeye论坛Q?/title><link>http://www.tkk7.com/jspark/archive/2006/08/28/66140.html</link><dc:creator>jspark</dc:creator><author>jspark</author><pubDate>Mon, 28 Aug 2006 03:58:00 GMT</pubDate><guid>http://www.tkk7.com/jspark/archive/2006/08/28/66140.html</guid><wfw:comment>http://www.tkk7.com/jspark/comments/66140.html</wfw:comment><comments>http://www.tkk7.com/jspark/archive/2006/08/28/66140.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jspark/comments/commentRss/66140.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jspark/services/trackbacks/66140.html</trackback:ping><description><![CDATA[ <p> </p> <table cellspacing="1" cellpadding="3" width="90%" align="center" border="0"> <tbody> <tr> <td> <span id="kcacoak" class="genmed">在spring中如何处理oracle大字D?<br /><br />在spring中采用OracleLobHandler来处理oracle大字D(包括clob和blobQ,则在E序中不需要引用oracle的特D类Q从而能够保证支持我们的代码支持多数据库?<br /><br />1、首先数据表中的clobcd对应java持久化类的StringcdQ而blobcd对应byte[]cd <br />2、定义hibernate标签Ӟ持久化类中对应clobcd的属性的hibernate type应ؓorg.springframework.orm.hibernate.support.ClobStringTypeQ而对应blobcd的属性的hibernate type应ؓorg.springframework.orm.hibernate.support.BlobByteArrayType?<br />3、以后访问这些对应clob和blobcd的属性时Q按普通属性处理,不需要特别编码?<br /><br /><strong>java代码: </strong></span> </td> </tr> <tr> <td class="code"> <div style="FONT-FAMILY: 'Courier New', Courier, monospace"> <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"> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">bean </span> <span style="COLOR: #ff0000">id</span> <span style="COLOR: #0000ff">="mySessionFactory2"</span> <span style="COLOR: #ff0000"> class</span> <span style="COLOR: #0000ff">="org.springframework.orm.hibernate.LocalSessionFactoryBean"</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />        </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">property </span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="dataSource"</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />                </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">ref </span> <span style="COLOR: #ff0000">bean</span> <span style="COLOR: #0000ff">="myDataSource2"</span> <span style="COLOR: #0000ff">/></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />         </span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">property</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />         </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">property </span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="lobHandler"</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />        </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">ref </span> <span style="COLOR: #ff0000">bean</span> <span style="COLOR: #0000ff">="oracleLobHandle"</span> <span style="COLOR: #0000ff">/></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />         </span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">property</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000">  <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">bean</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">bean </span> <span style="COLOR: #ff0000">id</span> <span style="COLOR: #0000ff">="nativeJdbcExtractor"</span> <span style="COLOR: #ff0000"> class</span> <span style="COLOR: #0000ff">="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor"</span> <span style="COLOR: #0000ff">/></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">bean </span> <span style="COLOR: #ff0000">id</span> <span style="COLOR: #0000ff">="oracleLobHandle"</span> <span style="COLOR: #ff0000"> class</span> <span style="COLOR: #0000ff">="org.springframework.jdbc.support.lob.OracleLobHandler"</span> <span style="COLOR: #ff0000"> Lazy-init</span> <span style="COLOR: #0000ff">="true"</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">property </span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="nativeJdbcExtractor"</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />    </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">ref </span> <span style="COLOR: #ff0000">local</span> <span style="COLOR: #0000ff">="nativejdbcExtractor"</span> <span style="COLOR: #0000ff">/></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">property</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">bean</span> <span style="COLOR: #0000ff">></span> </div> </div> <br /> </td> </tr> </tbody> </table> <br />Spring为处理数据库Lob字段Q特别提供了LobHandler接口。在操作Oracle RDBMSq程中,׃Oracle JDBC Driver实现的问题,应用必须采用Oracle原生的数据库q接Q比如,oracle.jdbc.OracleConnectionQ、LOB原生实现Q比如,oracle.sql.BLOB、oracle.sql.CLOBQ。因此,LobHandler接口存在上述两种实现。简而言之,为操作Oracle数据库,必须使用OracleLobHandler实现。如果操作其他RDBMScdQ则使用DefaultLobHandler。NativeJdbcExtractor是个接口Q通过它能够抽象各U连接池。另外Springq提供两个接口存取BlobQLobCreator及LobHandler <br /><img src ="http://www.tkk7.com/jspark/aggbug/66140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jspark/" target="_blank">jspark</a> 2006-08-28 11:58 <a href="http://www.tkk7.com/jspark/archive/2006/08/28/66140.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java政则表达式的子序列(groupQ?/title><link>http://www.tkk7.com/jspark/archive/2006/08/15/63687.html</link><dc:creator>jspark</dc:creator><author>jspark</author><pubDate>Tue, 15 Aug 2006 07:30:00 GMT</pubDate><guid>http://www.tkk7.com/jspark/archive/2006/08/15/63687.html</guid><wfw:comment>http://www.tkk7.com/jspark/comments/63687.html</wfw:comment><comments>http://www.tkk7.com/jspark/archive/2006/08/15/63687.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jspark/comments/commentRss/63687.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jspark/services/trackbacks/63687.html</trackback:ping><description><![CDATA[ <p>   jdk提供的正则表辑ּ是非常强大的Q只要用q正则表辑ּ的程序员应该是ؓ其功能叹止。不q,正则表达式中的一个group概念怿应该不多人熟悉?/p> <p>    正则表达式中的groupQ主要是用来区分子序列的Q所谓子序列是用()之内的表辑ּ。下面以一D늨序ؓ?br /></p> <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"> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">        String regex = "\\$\\{(I)(love)(java)\\}";<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />        System.out.println(Pattern.compile(regex).matcher("${Ilovejava}P)").groupCount());</span> </div> <br /> q行上面的代码段Q结果ؓQ?<br /> 其中(I)Z个组Q?(love)Z个组Q?java)Z个组?br /><br />  <br />  也许有h觉得q只是一个小功能Q但是正则表辑ּ的groupQ还有一个更加强大的地方是在String.replaceAllҎ中?br />  public <a title="java.lang 中的c? href="mk:@MSITStore:C:\Documents%20and%20Settings\hushaofeng\桌面\JAVA5.0API_CN.CHM::/java/lang/String.html">String</a><b>replaceAll</b>(<a title="java.lang 中的c? href="mk:@MSITStore:C:\Documents%20and%20Settings\hushaofeng\桌面\JAVA5.0API_CN.CHM::/java/lang/String.html">String</a> regex,<br />                         <a title="java.lang 中的c? href="mk:@MSITStore:C:\Documents%20and%20Settings\hushaofeng\桌面\JAVA5.0API_CN.CHM::/java/lang/String.html">String</a> replacement)<br /><br /> 其中W一个参数当然是政则表达式,W二个一般是普通的文本Q但是第二个参数可以应用group的地方,q个功能用在一些场合是非常方便的?br />      比如Q下面这个例子?<driverClass>${driverClass}</driverClass>Q要?{}LQ即这个例子替换成<driverClass>driverClass</driverClass>,可以用下面的代码来替换。例?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"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">        String text = "</span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">driverClass</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">${driverClass}</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">driverClass</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">";<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />        String result = replaceStr(text,"\\$\\{(driverClass)\\}","$1");<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />        System.out.println("result is:"+result);</span></div><br />   q行l果Qresult is:<driverClass>driverClass</driverClass><br />  从上面可以看出,$1是正则表达式中匚w的第一个序列,同样$2...表示W几个序列。如?index中的index出了表辑ּ中子序列的个数的话,抛出异怿息?$0表示整个正则表达式?img src ="http://www.tkk7.com/jspark/aggbug/63687.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jspark/" target="_blank">jspark</a> 2006-08-15 15:30 <a href="http://www.tkk7.com/jspark/archive/2006/08/15/63687.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcat5.0与tomcat5.5的数据库q接池jndi配置区别http://www.tkk7.com/jspark/archive/2006/08/11/62989.htmljsparkjsparkFri, 11 Aug 2006 06:03:00 GMThttp://www.tkk7.com/jspark/archive/2006/08/11/62989.htmlhttp://www.tkk7.com/jspark/comments/62989.htmlhttp://www.tkk7.com/jspark/archive/2006/08/11/62989.html#Feedback1http://www.tkk7.com/jspark/comments/commentRss/62989.htmlhttp://www.tkk7.com/jspark/services/trackbacks/62989.html
tomcat5.5出来后,jndi的配|方法是大大地节省,而且很简z,个h觉得比以前的版本好很多。这里大概给Z个配|例子。tomcat数据库连接池jndi配置有两U,一U是全局的,一U是context的,下面主要是讲全局的,q且以一个实例jdbc/byisdbZ?br />   
一、tomcat5.0配置Ҏ

1、首先在server.xml里面配置Q找C面的配置
  <!-- Global JNDI resources -->
  <GlobalNamingResources>
 </GlobalNamingResources>

2、在里面增加一个Resource
      <Resource name="jdbc/byisdb"
               auth
="Container"
               type
="javax.sql.DataSource"/>


3、在下面增加属?br />
  <ResourceParams name="jdbc/byisdb">
    
<parameter>
      
<name>factory</name>
      
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    
</parameter>

    
<!-- Maximum number of dB connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to 
0 for no limit.
         
-->
    
<parameter>
      
<name>maxActive</name>
      
<value>100</value>
    
</parameter>

    
<!-- Maximum number of idle dB connections to retain in pool.
         Set to 
-1 for no limit.  See also the DBCP documentation on this
         and the minEvictableIdleTimeMillis configuration parameter.
         
-->
    
<parameter>
      
<name>maxIdle</name>
      
<value>30</value>
    
</parameter>

    
<!-- Maximum time to wait for a dB connection to become available
         in ms, in 
this example 10 seconds. An Exception is thrown if
         
this timeout is exceeded.  Set to -1 to wait indefinitely.
         
-->
    
<parameter>
      
<name>maxWait</name>
      
<value>10000</value>
    
</parameter>

    
<!-- MySQL dB username and password for dB connections  -->
    
<parameter>
     
<name>username</name>
     
<value>una_oa</value>
    
</parameter>
    
<parameter>
     
<name>password</name>
     
<value>una_oa</value>
    
</parameter>

    
<!-- Class name for the old mm.mysql JDBC driver - uncomment this entry and comment next
         
if you want to use this driver - we recommend using Connector/J though
    
<parameter>
       
<name>driverClassName</name>
       
<value>org.gjt.mm.mysql.Driver</value>
    
</parameter>
     
-->
    
    
<!-- Class name for the official MySQL Connector/J driver -->
    
<parameter>
       
<name>driverClassName</name>
       
<value>oracle.jdbc.driver.OracleDriver</value>
    
</parameter>
    
    
<!-- The JDBC connection url for connecting to your MySQL dB.
         The autoReconnect
=true argument to the url makes sure that the
         mm.mysql JDBC Driver will automatically reconnect 
if mysqld closed the
         connection.  mysqld by 
default closes idle connections after 8 hours.
         
-->
    
<parameter>
      
<name>url</name>
      
<value>jdbc:oracle:thin:@192.168.1.210:1521:byisdb</value>
    
</parameter>
  
</ResourceParams>

4、在你的应用的web.xml里面增加
<resource-ref>
 
<description>postgreSQL Datasource example</description>
 
<res-ref-name>jdbc/byisdb</res-ref-name>
 
<res-type>javax.sql.DataSource</res-type>
 
<res-auth>Container</res-auth>
</resource-ref>

OK,到此配置完毕Q可以用下面的几D代码进行测?br />

Context initContext = new InitialContext();
Context envContext  
= (Context)initContext.lookup("java:/comp/env");
DataSource ds 
= (DataSource)envContext.lookup("jdbc/byisdb");
Connection conn 
= ds.getConnection();
out.println(
"conn is:"+conn);

二、tomcat5.5配置

1、打开conf/context.xml里面
  d下面的配|?br />

    <Resource name="jdbc/byisdb" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.1.210:1521:byisdb" username="una_oa" password="una_oa" maxActive="20" maxIdle="10" maxWait="10000"/>

 

2在你的应用的web.xml里面增加

<resource-ref>
 
<description>postgreSQL Datasource example</description>
 
<res-ref-name>jdbc/byisdb</res-ref-name>
 
<res-type>javax.sql.DataSource</res-type>
 
<res-auth>Container</res-auth>
</resource-ref>

同样Q可以用上面的代码进行测试?img src ="http://www.tkk7.com/jspark/aggbug/62989.html" width = "1" height = "1" />

jspark 2006-08-11 14:03 发表评论
]]>
վ֩ģ壺 Ƶۿ| Ļ˾Ʒ| һӰԺ| һ| ޹˾þ77| ޽Сxxxxɫ| sihuƷ| ñIJԭӾѹۿ| èwww˳| Ļó| þ㽶߿ۿƬ| ޵һƷӰ| ҹҹˬŮ8888Ƶѹۿ| һѹۿ| yw855.cƵ| ͼƬһ| һ˿wwwѸ| պƷר| ޵һҳۺͼƬ| С˵ͼƬƵ| eeussӰԺsscom| ŮƵ| ۺϾƷ㽶þ| ŷһվ7777 | ѻɫƬ| Ľղ2020| Ҹ| aaaƵѹۿ | ޾Ʒ߹ۿ| 99re99reƵֻ| ҹavӰԺ| AVרAV| Ƭ߹ۿ| ޹Ӱ߹ۿ| 88avѹۿ| ޳xxxxxӰ| 99þ99þѾƷС˵| þԭavapp| þþƷѹۿ| þþþavר| ѹۿ|