<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.qzone.qq.com/rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://qzone.qq.com">
<channel>
<title><![CDATA[峰]]></title>
<description><![CDATA[78258520]]></description>
<link>http://78258520.qzone.qq.com</link>
<lastBuildDate>Wed, 25 Nov 2009 23:06:26 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, Tencent Tech. Co., Ltd.</copyright>
<pubDate>Fri, 28 Aug 2009 01:27:29 GMT</pubDate>

<item>
<title><![CDATA[机米]]></title>
<link>http://78258520.qzone.qq.com/blog/1251422849</link>
<description><![CDATA[迷宫般的城市，让人习惯看相同的景物，走相同的路线，到相同的目的地；习惯让人的生活不再变化。习惯让人有种莫名的安全感，却又有种莫名的寂寞。<br>而你永远不知道，你的习惯会让你错过什么。<wbr /><a href="http://old.jimmyspa.com/solo/img/img_bk03_p2.jpg" target="_blank"><img style="width:310px;height:281px;border:0;" src="http://old.jimmyspa.com/solo/img/img_bk03_p2.jpg" /></a><wbr /><wbr /><a href="http://old.jimmyspa.com/solo/img/img_bk03_p1.jpg" target="_blank"><img style="width:310px;height:281px;border:0;" src="http://old.jimmyspa.com/solo/img/img_bk03_p1.jpg" /></a><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1251422849#comment</comments>
<qz:effect>134218241</qz:effect>
<pubDate>Fri, 28 Aug 2009 01:27:29 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1251422849</guid>
</item>

<item>
<title><![CDATA[星空]]></title>
<link>http://78258520.qzone.qq.com/blog/1249403894</link>
<description><![CDATA[有阴影的地方，必定有光<br>孤单时，仍要守护你心中的思念<br><br>那时候，未来遥远而没有形状，梦想还不知道该叫什么名字。 我常常一个人，走很长的路，在起风的时候觉得自己像一片落叶。仰望星空，我想知道：有人正从世界的某个地方朝我走来吗？像光那样，从一颗星到达另外一颗星。后来，你出现了。又离开了。我们等候着青春，却错过了彼此。<br> <wbr /><a href="http://old.jimmyspa.com/solo/img/img_bk01_p3.jpg" target="_blank"><img style="width:600px;height:422px;border:0;" src="http://old.jimmyspa.com/solo/img/img_bk01_p3.jpg" /></a><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1249403894#comment</comments>
<qz:effect>134217729</qz:effect>
<pubDate>Tue, 04 Aug 2009 16:38:14 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1249403894</guid>
</item>

<item>
<title><![CDATA[利用JasperReport+iReport进行Web报表开发]]></title>
<link>http://78258520.qzone.qq.com/blog/1190250510</link>
<description><![CDATA[<span style="font-size:32px;line-height:1.8em;">JasperReport+iReport高级报表设计实战</span><wbr /> <br>序言<br>一直以来，报表都是很多项目中一个重要的、不可获取的组成部分。然而其复杂性和专业性又使得程序员不能够也没时间自己设计属于目前手头正在构建的系统的报表模块；即便设计来了又可能由于通用性等原因不能够应用到下一个系统当中，这就导致了报表类库/组件在市场上的火爆。典型的例子就是水晶报表，几乎无处不在。还有一些专门处理中国式报表的组件也陆续出现在软件市场上。然而遗憾的是，他们中的绝大多数都是要收费的--这也无可厚非，毕竟人都是要生存的。所以大多数预算不够充裕的程序员都将目光转向了开源软件，而JasperReport就将是第一个进入他们视线中的佼佼者。<br>然而代码开源不代表我们就可以大大方方的拿来就用了，人家的文档也是要收费的，所以市面上有关于JasperReport的文档虽然也不少，但大多数都集中在简单应用和介绍基本操作的基础之上。对于复杂的报表设计并不能提供良好的帮助。本文将火力集中在相对复杂的报表设计（不包括图片和超连接等对办公系统或过程没有太大用途的页面元素），交叉表的生成等高级报表设计方案。对于那些基本的操作则留给读者自行体会，相信可以为各位解决一些实际问题。<br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354707" target="_blank">1     iReport概览... 4</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354708" target="_blank">2.1.     准备工作... 5</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354709" target="_blank">1.1.1       Database JDBC Connection Datasource. 5</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354710" target="_blank">1.1.2       JavaBean Set Datasource. 7</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354711" target="_blank">2     实战报表设计... 10</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354712" target="_blank">2.1      简单的复杂表头报表设计... 12</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354713" target="_blank">2.2      交叉表的设计... 13</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354714" target="_blank">2.2.1       利用iReport向导生成交叉表架构... 13</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354715" target="_blank">2.2.2       偷懒的解决方案... 16</a><wbr /><br><a href="http://writeblog.csdn.net/Editor/FCKeditor/editor/fckeditor.html?InstanceName=ctl00_ContentPlaceHolder1_EntryEditor1_richTextEditor_richTextEditor&amp;Toolbar=Default#_Toc158354716" target="_blank">3     结束语... 17</a><wbr /><br> <br><span style="font-weight:bold"><wbr /><span style="font-size:32px;line-height:1.8em;">1   iReport概览</span><wbr /></span><wbr /><br>JasperReport是JasperSoft公司的一款开源的报表解决方案。通过JasperReport，用户就可以方便的定制、设计、生成项目所需要的各种报表。和JasperReport一样，iReport也是Sourceforg上的开源项目。它的出现，主要是为了降低JasperReport的使用难度，为用户提供可视化的报表设计工具，目前iReport的版本号为1.2.7。<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/7db5fee475674fcabae52e92b4554107.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/7db5fee475674fcabae52e92b4554107.png" /></a><wbr /></div>每个版本的iReport都会与最新的JasperReport相匹配的功能，并可以手动设置与用户所使用的JasperReport兼容性，以便怀旧的用户可以无障碍地使用最新的iReport：<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/e39e8fe2c8e542e1b21e2145721b0000.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/e39e8fe2c8e542e1b21e2145721b0000.png" /></a><wbr /></div>限于篇幅，我不可能把iReport操作的每一个细节都记录在本文中，而只能对涉及到的部分作出简要介绍，剩下的诸如报表中的各个报表元素是什么，属性都有什么；什么是iReport的字段（Filed），参数（parameter）和变量（variable）等等这些基本概念，如果想要深究细节的话有两种选择：1是寻找其官方文档（要收费），网上流传的文档版本较低，但是也可以作为参考，如果想要我翻译的JasperReport用户文档，可以给我发邮件。2是自己动手实践一下吧。<br><span style="font-weight:bold"><wbr /><span style="font-size:24px;line-height:1.8em;">2.1.     准备工作</span><wbr /></span><wbr /><br>做报表的目的就是显示数据，无论是简单的查询结果还是某些统计信息。所以我们第一步要做的就是设定iReport中的数据源或数据库连接，以便于从数据库中动态获取数据。在菜单-&gt;Connection and Datasource里我们可以设定所要采用的数据提供方式。iReport为我们提供了丰富的选项：<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/4963a9e448a34b04b16c1a9cdf705902.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/4963a9e448a34b04b16c1a9cdf705902.png" /></a><wbr /></div>通常情况下，我们一般有两种选择，一是选择数据库连结的数据源，通过这种方式，我们就可以直接在报表设计中写入SQL查询语句，让报表在运行期自动获取所需的数据来装填报表而不需要做额外的工作。但这样一来，就必然会损失一些程序的灵活性，比如查询语句或数据库连接需要修改的时候我们就不得不重新填入相应的内容并编译报表。所以我在工作中通常采用第二种方式，即用JavaBean的集合（Collection或Array）来充当数据源。下面我就分别介绍这两种连接方式：<br><span style="font-weight:bold"><wbr /><span style="font-size:18px;line-height:1.8em;">1.1.1Database JDBC Connection Datasource</span><wbr /></span><wbr /><br>假设我要采用的数据库连接是MySQL，所以需要选择“Database JDBC Connection”方法：<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/8fea0f42559b43348e6e27d2ec111452.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/8fea0f42559b43348e6e27d2ec111452.png" /></a><wbr /></div>我们可以根据自己的实际情况来建立数据库连接。值得一提的是，iReport为我们提供我们在实际项目中会遇到的几乎全部的JDBC驱动，不管你用的是MySQL，DB2，Orcale还是hsqldb和cloudscape，着实是十分方便。在设定好连接之后，我们就可以在“编辑-&gt;报表查询”中输入在报表填充所需的查询语句。如果你设置无误的话，在你输入SQL语句之后，iReport会自动为你显示出你要使用的表的属性都有哪些：<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/57d4a7145f00428eab77e57d8331737e.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/57d4a7145f00428eab77e57d8331737e.png" /></a><wbr /></div>例如，我的数据库中的表“ky_kyxtbmb”中的属性在我填入sql语句之后被自动显示在了下面。对于简单的报表来说，这样做着实很方便。但是如果SQL查询或数据库连接需要变更的话，就需要重新填入SQL或数据库联接的信息，并编译报表设计，这显然是在损失了灵活性之后所获得的方便。所以通常我都采用第二种方式。<br><span style="font-weight:bold"><wbr /><span style="font-size:18px;line-height:1.8em;">1.1.2JavaBean Set Datasource</span><wbr /></span><wbr /><br>我们点击“数据=〉连接/数据源=〉新建数据源”（如下图所示）。数据源类型我们要选择JavaBean set datasource。选项中Factory Class是用来生成Bean数据源的工厂类，它至少包含一个叫做createBeanCollection的方法（当然也可以叫其他的名字）。该工厂类用于为报表提供一个数组或集合类作为数据源，由报表引擎在运行期负责将数据读出，并装填到报表相应的字段。在利用iReport进行测试的时候，iReport会利用reflection功能在运行期创建一个看不见的工厂类，并调用其静态的数据源生成方法来生成数据源，最后交给报表引擎负责装填。<br><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/d4c22e98d8bc4d0a974b64aecd11ff8a.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/d4c22e98d8bc4d0a974b64aecd11ff8a.png" /></a><wbr /><br>这里应该注意的是，JavaBean中的每一个字段都应该对应报表设计中的一个Field，这一点我们很快就会看到。再有就是我们看到iReport在指定生成数据源的静态方法的时候并没有给我们提供设置方法参数的功能，也就是说如果你的方法需要参数的话你就不能使用iReport来进行测试。不过这并不会产生很大的影响，我们在程序里测试就是了。<br><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/0fdd799b889d498dbd9db3b5cc8878be.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/0fdd799b889d498dbd9db3b5cc8878be.png" /></a><wbr /><br>随后我们要做的是在“选项-〉classpath”中设定classpath，以便iReport能够找到我们定义的工厂类和相应的JavaBean类。最后，我们在“数据-〉报表查询-〉JavaBean数据源”中的类名文本框中填入JavaBean的全限定名，就可以获得JavaBean的字段名。这时选择“Add Selected Fields”就可以将这些字段变成报表中的“Field”，于是我们就可以在报表设计中通过“$F{字段名}”来使用它们了。下面是一个使用JavaBean数组作为数据源的例子：<br>public class SRDataSourceFactory {<br> <br>    /************************************************************************<br>     * 生成实验室人员知识年龄结构情况的数据源<br>     * @return JRDataSource<br>     ************************************************************************/<br>    public static JRDataSource createILabMemberInfoDS() throws Exception {<br>        JRBeanCollectionDataSource ds = null;<br>        ArrayList beans = createILabMemberInfoCollection();<br>        ds = new JRBeanCollectionDataSource(beans);<br>        return ds;<br>    }<br> <br>public static ArrayList createILabMemberInfoCollection() throws Exception {<br>        Connection conn = DBConnection.getConnection();//获得数据库连接<br>        ArrayList&lt;ILabMemberInfoBean&gt; beans = new ArrayList&lt;ILabMemberInfoBean&gt;();<br>        ILabPaperIndexedBean newBean;<br> <br>        /**<br>* @todo 下面的代码主要是将数据填入到newBean中，然后将newBean放入到数组beans里<br>        *       这里就不详述了。 <br>*/    <br>        ……<br>        return beans;<br>    }<br> <br><span style="font-weight:bold"><wbr /><span style="font-size:32px;line-height:1.8em;">2   实战报表设计</span><wbr /></span><wbr /><br>在实际应用中，很多报表都是用于显示对数据库信息进行统计查询的结果，所以这些报表都不是简单的二维表，而是带有复杂的表头的报表，又或表头的项目数量也是动态的交叉表。对第一种种报表来说，虽然其表头复杂，但报表的框架却是静态的，仅需要花费些时间在设计统计查询语句上，采用JavaBean作为数据源，运行期由数据库动态读取数据装填到报表中就可以了，所以我称之为“简单的”，具体实例见表格 2.1?1和2.1?2。第二种报表比之前一种复杂了很多，像表格 2.1?3，这种表多用于显示统计查询的结果，其列的数量在运行期才能知晓。这需要报表工具专门的支持，而JasperReport为我们提供了支持这种交叉表的“有限”能力。而表格 2.1?4的情况就更为复杂了，不但列是动态生成的，而且每一列都是复合表头。复合表头也就罢了，然而其表头的第二层（即指“项目数”和“经费”一层）又来源于不同的属性，这就超出了目前JasperReport和iReport的能力范畴（至于具体为甚么不能做我在下文还会有交待）。但我们还是有解决的方法：我们或者限定表的列数（这样就成了固定表头的简单报表了）；或者干脆就只能利用JaperReport的API来用程序动态生成报表设计，然而这显然是十分复杂的和费事的，也超出了本文的范畴，在这里就不详述了。下面我们就来看如何实现JasperReport和iReport能力所及的报表的设计。<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/af645f0602d744e9a781f5b9d3422f52.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/af645f0602d744e9a781f5b9d3422f52.png" /></a><wbr /></div><div style="text-align:center;">图表 2.1?1复杂表头的简单报表（1）</div><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/79e5763831774fbe8f69a30e4dc8dd4d.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/79e5763831774fbe8f69a30e4dc8dd4d.png" /></a><wbr /></div><div style="text-align:center;">图表 2.1?2复杂表头的简单报表（2）</div><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/7413977daa054031b13d1c5605193331.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/7413977daa054031b13d1c5605193331.png" /></a><wbr /><br><div style="text-align:center;">图表 2.1?3 简单的交叉表</div><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/7ee78fa8f32f4bb197df2aa090957a4b.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/7ee78fa8f32f4bb197df2aa090957a4b.png" /></a><wbr /><br><div style="text-align:center;">图表 2.1?4 复杂的交叉表</div> <br><span style="font-weight:bold"><wbr /><span style="font-size:24px;line-height:1.8em;">2.1简单的复杂表头报表设计</span><wbr /></span><wbr /><br>我的例子报表设计在设计器中显示的效果如下所示：<br><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/a645ef223c2349c3bed31ada540aebec.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/a645ef223c2349c3bed31ada540aebec.png" /></a><wbr /><br>这个报表结构十分简单，并没有用到Group和Subreport及交叉表之类高级技术的，仅仅是为了说明复杂表头其实并不“复杂”。这个报表的作用是显示几个数据库表作统计查询结果，只要你在准备工作中正确的设置了参数（Parameter）和字段（Field），并输入了正确的查询语句，就可以获得想要的结果。<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/efbe1bf18ddc492d9da92c6c222d7271.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/efbe1bf18ddc492d9da92c6c222d7271.png" /></a><wbr /></div><span style="font-weight:bold"><wbr /><span style="font-size:24px;line-height:1.8em;">2.2交叉表的设计</span><wbr /></span><wbr /><br>交叉表（Crosstab—Cross Tabulation）是包含行列合计内容的表格，多用于显示统计结果，在工作中十分常用。JasperReport是在JasperReport1.1中开始支持这项功能的，然而其功能目前仍显稚嫩，还不能完成更为复杂的一些的操作，如图表 2.1?4。不过聊胜于无，BIRT要到下一个版本才支持交叉表呢。下面就让我们具体看一下如何生成像图表 2.1?3这样行列都带统计，且右下角的方格显示总计数值的报表设计吧。<br><span style="font-weight:bold"><wbr /><span style="font-size:18px;line-height:1.8em;">2.2.1利用iReport向导生成交叉表架构</span><wbr /></span><wbr /><br>首先我们生成一个新的报表，在其summery带中放置一个交叉表，这时iReport就会出现交叉表生成向导来帮助我们设置交叉表的结构。跟据图2.1?3的结构，我们看到表的行是飞机要飞往的城市名称，而列示飞机行班的名字。每一列的total指在每一个城市中某一架飞机的航班数，而每行的total表示某一城市中所有航班的数量，表的右下角为所有城市的总航班数。<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/7a07b4de94df42309842265a3dc67f0f.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/7a07b4de94df42309842265a3dc67f0f.png" /></a><wbr /></div>可以看到，iReport的向导默认给我们提供了两个Row Group的能力，举例来说，我们扩展图2.1?3，使其显示每个州的各个城市的飞机航班情况，就需要将Row Group1 设置为州（省）所对应的属性，而将Row Group 2置为城市所对应的属性。同样，我们也可以设置2个Column Group。但需要注意的是，我们发现这样的配置是不可能实现例如表2.1?4这样的结构的。因为表2.1?4中对应Column Group2的部分并不是取自一个属性，这样JasperReport就无法将其组织在一个格中。所以我们只能实现比2.1?3的行/列多一个Group（即行列各多一维）但属性为单一属性的报表，而无法生成类似于2.1?4这样的复杂结构。最后要说的是，如果有需要的话我们可以交叉表向导结束之后自行在交叉表的属性选项卡中加入新的行/列Group，而不仅仅局限于iReport向导中提供的两个。<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/60b24a1932844410b0c7c13e33cc74a1.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/60b24a1932844410b0c7c13e33cc74a1.png" /></a><wbr /></div>在表的内容（Detail Field）部分我们也可以有如上图所示的3种选择，这一选项用来指示JasperReport如何进行运算。最后我们可以定义对total的配置，即是否加入行总计，是否加入列总计和是否显示表格线，本例中我们都是需要的。<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/1b4d55f3ca6d4e34a6a952bca2c086a0.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/1b4d55f3ca6d4e34a6a952bca2c086a0.png" /></a><wbr /></div>至此，表格的基本骨架生成完毕，我们可以在设计器中看到如下内容：<br><div style="text-align:center;"><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/291ab1bd33d54d00ad90df6cb50c3197.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/291ab1bd33d54d00ad90df6cb50c3197.png" /></a><wbr /></div>然后我们在查询窗口写如下查询语句即可：<br><wbr /><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/9ded561a695741dea15cacaa3d6daba8.png" target="_blank"><img style="border:0;" src="http://p.blog.csdn.net/images/p_blog_csdn_net/kabini/9ded561a695741dea15cacaa3d6daba8.png" /></a><wbr /><br>可以看到，我们并没有使用任何统计查询的语句，而JasperReport就能为我们自动进行统计运算，并将结果填入指定位置，它是怎么做到的呢？细心的人可能已经看出一点问题来了，怎么报表设计中的文本框里写的都是变量V而不是我们常用的字段F呢？这就是原因所在，JasperReport通过一个“Measure”，即我们在Detail Field部分定义的属性，根据其运算类型（包括Average, Count, First, Highest, Lowest, Nothing, StandardDeviation, Sum和Variance.）来对行/列的数量进行运算，并将结果存放在内部变量中（这些变量我们在iReport的变量查看器中是看不见的），并利用这些变量来显示统计结果。然而我们可以清楚地看到，这样的功能设定还是有很多问题的，例如如果我们的统计查询不能够仅由一条查询语句就能表示怎么办？就算用一条查询就能表示的统计，遇到像表2.1?4这样的结构我们照样无计可施。所以在实在需要的情况下我们就只能借助于JasperReportAPI动态生成报表的JRXML文件来获得想要的灵活性，这是JasperReport的万灵丹，只不过需要付出更多的精力罢了。在JasperReport和IReport变得更强大之前，我们也就只能利用现有的工具作一些有限的工作了。<br><span style="font-weight:bold"><wbr /><span style="font-size:18px;line-height:1.8em;">2.2.2偷懒的解决方案</span><wbr /></span><wbr /><br>对于交叉表来说，其难点在于报表的内容属于统计查询，不是一个查询语句就能获得所有想要的数据，而且表的列是不能在设计期就知晓的，进而不能像准备工作中所提到的那样设置一条查询就完事大吉。但是也可以有一个比较省事的方法是：将报表所需要的所有数据在数据库提取出来之后放到一个临时的表（或其他JasperReport数据源所支持的数据结构中，例如JavaBean）然后再将数据逐一填到报表中。对于表格 2.1?2这样的报表，这种方法既实用又很简单，但是这种做法不适合列也是动态的交叉表—例如表格 2.1?3。所以对于最后一种情况我们就没什么好说的，必须使用JasperReport的Crosstab的相关功能了。以上就是利用JasperReport+iReport进行报表设计的全部内容，限于篇幅，我只能尽量挑选一些网上人们问题的最多的普遍问题加以解释，说明了什么是JasperReport能做的，什么是它不能做或做起来很麻烦的，也大略讲解了究竟怎么做。希望能给各位在做报表时提供一点帮助。<br><span style="font-weight:bold"><wbr /><span style="font-size:32px;line-height:1.8em;">3   结束语</span><wbr /></span><wbr /><br>作者简介：本文作者薛笛，是黑龙江大学研究生。他目前在黑龙江大学信息技术研究所工作，从事传感器网络和移动数据库的研究，对Java技术特别感兴趣。可以通过 jxuedi@gmail.com 与他联系 <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1190250510#comment</comments>
<qz:effect>513</qz:effect>
<pubDate>Thu, 20 Sep 2007 01:08:30 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1190250510</guid>
</item>

<item>
<title><![CDATA[iReport和JasperReport的整合详解]]></title>
<link>http://78258520.qzone.qq.com/blog/1190250313</link>
<description><![CDATA[<a href="http://mooncome1983.blogchina.com/inc/iReport%23index.htm" target="_blank">http://mooncome1983.blogchina.com/inc/iReport%23index.htm</a><wbr /><br> <br> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1190250313#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Thu, 20 Sep 2007 01:05:13 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1190250313</guid>
</item>

<item>
<title><![CDATA[Cewolf生成web图表]]></title>
<link>http://78258520.qzone.qq.com/blog/1190249903</link>
<description><![CDATA[<a href="http://www.netjava.org/frame.php?frameon=yes&amp;referer=http%3A//www.netjava.org/viewthread.php%3Ftid%3D6%26extra%3Dpage%253D2" target="_blank">http://www.netjava.org/frame.php?frameon=yes&amp;referer=http%3A//www.netjava.org/viewthread.php%3Ftid%3D6%26extra%3Dpage%253D2</a><wbr /><br> <br> <br><a href="http://cewolf.sourceforge.net/new/index.html" target="_blank">Cewolf</a><wbr />可以做为在jsp，servlet程序展示复杂的line，bat，chart图表，而不需要编写复杂的jsp脚本，通过Cewolf的tag即可完成。Cewolf底层是基于<a href="http://www.jfree.org/jfreechart/index.html" target="_blank">jFreeCharts</a><wbr />库的，它对jf做了较好的封装，以便简洁在web页面中展示。<br>     本示例展示一个简单的web条形图，当mouse放到某一条形图上时，可以显示相关提示，并具有导航做用，如下图：<br>     <wbr /><a href="http:///" target="_blank"><img style="border:0;" src="http:///" /></a><wbr /><br><br>1.首先<a href="http://cewolf.sourceforge.net/new/index.html" target="_blank">下载</a><wbr />cewolf类库,配置系统(本例子基于1.0版本):<br>       A.将cewolf类库文件放到web-inf/lib/下面;<br>       B.考贝overlib.js、cewolf.tld、cewolf-1.1.tld三个文件到web-inf/下面；<br>     C.在你的web目录下的web-inf/web.xml配置Cewolf处理器,在web.xml中添加如下配置:<br><br><a href="http://www.netjava.org/viewthread.php?tid=6&amp;extra=page=2&amp;frameon=no###" target="_blank">[Copy to clipboard]</a><wbr /> <a href="http://www.netjava.org/viewthread.php?tid=6&amp;extra=page=2&amp;frameon=no###" target="_blank">[ - ]</a><wbr /><br>CODE:&amp;lt;servlet&amp;gt;    <br>            &amp;lt;servlet-name&amp;gt;CewolfServlet&amp;lt;/servlet-name&amp;gt;    <br>            &amp;lt;servlet-class&amp;gt;de.laures.cewolf.CewolfRenderer&amp;lt;/servlet-class&amp;gt;<br>              &amp;lt;init-param&amp;gt;<br>                  &amp;lt;param-name&amp;gt;storage&amp;lt;/param-name&amp;gt;<br>                  &amp;lt;param-value&amp;gt;de.laures.cewolf.storage.TransientSessionStorage&amp;lt;/param-value&amp;gt;<br>              &amp;lt;/init-param&amp;gt;<br>        &amp;lt;!-- sets overlib.js location relative to webapp --&amp;gt;<br>              &amp;lt;init-param&amp;gt;<br>                 &amp;lt;param-name&amp;gt;overliburl&amp;lt;/param-name&amp;gt;<br>                 &amp;lt;param-value&amp;gt;overlib.js&amp;lt;/param-value&amp;gt;<br>             &amp;lt;/init-param&amp;gt;<br>        &amp;lt;!-- turn on or off debugging logging --&amp;gt;<br>              &amp;lt;init-param&amp;gt;<br>                  &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;<br>                  &amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;<br>               &amp;lt;/init-param&amp;gt;<br>                &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;<br>        &amp;lt;/servlet&amp;gt;<br><br>    &amp;lt;servlet-mapping&amp;gt;    <br>                  &amp;lt;servlet-name&amp;gt;CewolfServlet&amp;lt;/servlet-name&amp;gt;  <br>                 &amp;lt;url-pattern&amp;gt;/cewolf/*&amp;lt;/url-pattern&amp;gt;<br>    &amp;lt;/servlet-mapping&amp;gt;<br><br>   <br>2.编写一个数据提供Bean: TestCewolf.java<br>注意编写时要引入相关类库，编译后打包放入web-inf/lib下，<br><br><a href="http://www.netjava.org/viewthread.php?tid=6&amp;extra=page=2&amp;frameon=no###" target="_blank">[Copy to clipboard]</a><wbr /> <a href="http://www.netjava.org/viewthread.php?tid=6&amp;extra=page=2&amp;frameon=no###" target="_blank">[ - ]</a><wbr /><br>CODE:package com.netjava.web;<br>import java.io.Serializable;<br>import java.util.*;<br><br>import org.jfree.data.category.CategoryDataset;<br>import org.jfree.data.category.DefaultCategoryDataset;<br><br>import de.laures.cewolf.DatasetProduceException;<br>import de.laures.cewolf.DatasetProducer;<br>import de.laures.cewolf.links.CategoryItemLinkGenerator;<br>import de.laures.cewolf.tooltips.CategoryToolTipGenerator;<br><br>import  org.jfree.data.xy.XYDataset;<br>import java.text.DateFormat;<br>import java.text.SimpleDateFormat;<br><br>/*<br>*@desc: 数据供应类的实现<br>*DatasetProducer接口：通过jf为页面tag提供数据,必须的<br>*CategoryToolTipGenerator:图表的提示信息接口，可选<br>*CategoryItemLinkGenerator:图表的超链uri接口提供，可选<br>*/<br>public class TestCewolf implements DatasetProducer, CategoryToolTipGenerator, CategoryItemLinkGenerator, Serializable {<br>    /** X轴  违法月份**/<br>    private final String&amp;#91;] categories =    {&quot;一月&quot;, &quot;二月&quot;, &quot;三月&quot;, &quot;四月&quot;, &quot;五月&quot;, &quot;六月&quot;, &quot;七月&quot;};<br>    /** y轴  违法地点 */<br>    private final String&amp;#91;] seriesNames =    {&quot;芙蓉路立交桥&quot;, &quot;五一立交桥&quot;, &quot;长岭路口&quot;, &quot;人民路与芙蓉路叉口&quot;};<br>    <br>    /**<br>     *实现DatasetProducer接口的数据提供方法,返回一个DefaultCategoryDataset对象；<br>     *  Produces some random data.<br>     */<br>    public Object produceDataset(Map params) throws DatasetProduceException {<br>        DefaultCategoryDataset dataset = new DefaultCategoryDataset();<br>        for (int series = 0; series &amp;lt; seriesNames.length; series ++) {<br>            int lastY = new Random().nextInt(500)+1000;//生成随机数据<br>            for (int i = 0; i &amp;lt; categories.length; i++) {<br>                int y = lastY + new Random().nextInt(500);<br>                dataset.addValue(y, seriesNames[series], categories<span style="font-style:italic"><wbr />);<br>            }<br>        }<br>        return dataset;<br>    }<br>    <br>    /**<br>     *检测数据是否过期的方法实现。<br>     * This producer's data is invalidated after 5 seconds. By this method the<br>     * producer can influence Cewolf's caching behaviour the way it wants to.<br>     */<br>    public boolean hasExpired(Map params, Date since) {<br>        return (System.currentTimeMillis() - since.getTime())  &amp;gt; 5000;<br>    }<br>    <br>    /**<br>     * Returns a unique ID for this DatasetProducer<br>     */<br>    public String getProducerId() {<br>        return &quot;sample traffic chart&quot;;<br>    }<br>    <br>    /**<br>     * 实现CategoryItemLinkGenerator接口的为指定图表生成链结ＵＲＩ<br>     * @param dataset the dataset<br>     * @param series the series number<br>     * @param category the category<br>     * @see org.jfree.data.CategoryDataset<br>     */<br>    public String generateLink(Object data, int series, Object category) {<br>        series+=1;<br>        return &quot;getDetail?series=&quot;+series;<br>        //+&quot;&amp;seriesNames=&quot;+seriesNames[series]<br>    }<br>    /**<br>     *成生提示信息<br>     * @see org.jfree.chart.tooltips.CategoryToolTipGenerator#generateToolTip(CategoryDataset, int, int)<br>     */<br>    public String generateToolTip(CategoryDataset arg0, int series, int arg2) {<br>        int yf=arg2+1;<br>        return   seriesNames[series]+yf+&quot;月份共有:&quot;+arg0.getValue(series,arg2)+&quot;次违法&quot;;<br>    }<br>    <br>    /**<br>     *清理资源实现<br>     * @see java.lang.Object#finalize()<br>     */<br>    protected void finalize() throws Throwable {<br>        super.finalize();<br>    }<br>}<br><br>3.编写展示页面displayChart.jsp<br><br><a href="http://www.netjava.org/viewthread.php?tid=6&amp;extra=page=2&amp;frameon=no###" target="_blank">[Copy to clipboard]</a><wbr /> <a href="http://www.netjava.org/viewthread.php?tid=6&amp;extra=page=2&amp;frameon=no###" target="_blank">[ - ]</a><wbr /><br>CODE:&amp;lt;%@page c%&amp;gt;<br>&amp;lt;%@page pageEncoding=&quot;UTF-8&quot;%&amp;gt;<br>&amp;lt;%@taglib uri=&quot;http://java.sun.com/jsp/jstl/core&quot; prefix=&quot;c&quot;%&amp;gt; <br>&amp;lt;!--指定cewolf的tld文件位置--&amp;gt;<br>&amp;lt;%@taglib uri='/WEB-INF/cewolf.tld' prefix='cewolf' %&amp;gt;<br>&amp;lt;title&amp;gt;NetJava.org&amp;lt;/title&amp;gt;<br>&amp;lt;HTML&amp;gt;&amp;lt;BODY&amp;gt;&amp;lt;H1&amp;gt;ePolice  Statistics&amp;lt;/H1&amp;gt;<br>   &amp;lt;HR&amp;gt;<br>   &amp;lt;!--指定数据供应类的实现--&amp;gt;<br>   &amp;lt;jsp:useBean id=&quot;wfProduce&quot; class=&quot;com.netjava.web.TestCewolf&quot;/&amp;gt;<br>  &amp;lt;!--在页面定义一个图表,分别为:图表id,标题，Y轴标题,图表类型，对文字是否做平滑处理，--&amp;gt;<br>    &amp;lt;cewolf:chart  id=&quot;wfChart&quot;  title=&quot;违法数据统计&quot;  yaxislabel=&quot;违法数量&quot; type=&quot;verticalbar3d&quot;  antialias=&quot;false&quot;&amp;gt;<br>           &amp;lt;cewolf:data&amp;gt; <br>               &amp;lt;!--指向数据提供bean－－&amp;gt;<br>               &amp;lt;cewolf:producer id=&quot;wfProduce&quot;/&amp;gt;    <br>          &amp;lt;/cewolf:data&amp;gt;<br>    &amp;lt;/cewolf:chart&amp;gt;<br>   <br>   &amp;lt;p&amp;gt;&amp;lt;!--在页面输出图片--&amp;gt;<br>     &amp;lt;cewolf:img  chartid=&quot;wfChart&quot;  renderer=&quot;cewolf&quot;   width=&quot;900&quot; height=&quot;360&quot; border=&quot;2&quot; &amp;gt;<br>         &amp;lt;!--指定图片提示及超链类的实现--&amp;gt;<br>             &amp;lt;cewolf:map    linkgeneratorid=&quot;wfProduce&quot;  tooltipgeneratorid=&quot;wfProduce&quot; /&amp;gt;<br>    &amp;lt;/cewolf:img&amp;gt;<br>  &amp;lt;/BODY&amp;gt;<br>&amp;lt;/HTML&amp;gt; <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1190249903#comment</comments>
<qz:effect>513</qz:effect>
<pubDate>Thu, 20 Sep 2007 00:58:23 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1190249903</guid>
</item>

<item>
<title><![CDATA[Cewolf配置]]></title>
<link>http://78258520.qzone.qq.com/blog/1190249762</link>
<description><![CDATA[<a href="http://www.java114.com/content.jsp?id=3542" target="_blank">http://www.java114.com/content.jsp?id=3542</a><wbr /><br> <br> <br>首先，下在最新版cewolf. http://sourceforge.net/project/showfiles.php?group_id=57282<br>解压后，我们可以在lib目录下看到jar文件： jfreechart-*-demo.jar jfreechart-*.jar jcommon-*.jar commons-logging.jar cewolf.jar batik-xml.jar batik-util.jar batik-svggen.jar batik-dom.jar batik-awt-util.jar   <br>我们可以上述的jar文件复制到应用程序的根目录下的\WEB-INF\lib子目录下，当然你也可以将解压后lib目下的所有jar拷贝到\WEB-INF\lib子目录下，然后呢，将/etc目录下的overlib.js复制到web应用程序的根目录下面，之后将/etc下面的cewolf.tld,cewolf-1.1.tld复制到web程序的根目录下面的\WEB-INF子目录下，最后将\WEB-INF\web.xml增加以下内容：<br><br><span style="line-height:1.8em;">&lt;web-app&gt;</span><wbr /><br><span style="line-height:1.8em;">  &lt;servlet&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;servlet-name&gt;CewolfServlet&lt;/servlet-name&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;servlet-class&gt;de.laures.cewolf.CewolfRenderer&lt;/servlet-class&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;!-- sets storage implementation --&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;init-param&gt;</span><wbr /><br><span style="line-height:1.8em;">        &lt;param-name&gt;storage&lt;/param-name&gt;</span><wbr /><br><span style="line-height:1.8em;">        &lt;param-value&gt;de.laures.cewolf.storage.TransientSessionStorage&lt;/param-value&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;/init-param&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;!-- sets overlib.js location relative to webapp --&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;init-param&gt;</span><wbr /><br><span style="line-height:1.8em;">        &lt;param-name&gt;overliburl&lt;/param-name&gt;</span><wbr /><br><span style="line-height:1.8em;">        &lt;param-value&gt;etc/overlib.js&lt;/param-value&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;/init-param&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;!-- turn on or off debugging logging --&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;init-param&gt;</span><wbr /><br><span style="line-height:1.8em;">        &lt;param-name&gt;debug&lt;/param-name&gt;</span><wbr /><br><span style="line-height:1.8em;">        &lt;param-value&gt;true&lt;/param-value&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;/init-param&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;</span><wbr /><br><span style="line-height:1.8em;">  &lt;/servlet&gt;</span><wbr /><br><br><span style="line-height:1.8em;">  &lt;servlet-mapping&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;servlet-name&gt;CewolfServlet&lt;/servlet-name&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;url-pattern&gt;/cewolf/*&lt;/url-pattern&gt;</span><wbr /><br><span style="line-height:1.8em;">  &lt;/servlet-mapping&gt;</span><wbr /><br><br><span style="line-height:1.8em;">  &lt;session-config&gt;</span><wbr /><br><span style="line-height:1.8em;">    &lt;session-timeout&gt;1&lt;/session-timeout&gt;</span><wbr /><br><span style="line-height:1.8em;">  &lt;/session-config&gt;</span><wbr /><br><span style="line-height:1.8em;">&lt;/web-app&gt;</span><wbr /><br><br><br><br><br><span style="font-family:'NSimsun';line-height:1.8em;">为了测试是否安装正确，重起tomcat,打开浏览器输入  http://localhost:8080/JSPWEB/cewolf?state</span><wbr /><br><span style="font-family:'NSimsun';line-height:1.8em;">(JSPWEB是你的应用程序的根目录）如果正确的话：显示：</span><wbr /><br><span style="font-weight:bold"><wbr />Cewolf servlet up and running.</span><wbr /><br>Requests served so far: 9<br>配置结束 <br><br>                                    <wbr /><a href="http://cewolf.sourceforge.net/new/img/tutorial.png" target="_blank"><img style="border:0;" src="http://cewolf.sourceforge.net/new/img/tutorial.png" /></a><wbr /><br>                                                                 Cewolf效果图<br> <br> <br> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1190249762#comment</comments>
<qz:effect>513</qz:effect>
<pubDate>Thu, 20 Sep 2007 00:56:02 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1190249762</guid>
</item>

<item>
<title><![CDATA[Java开源报表制作]]></title>
<link>http://78258520.qzone.qq.com/blog/1190249644</link>
<description><![CDATA[<a href="http://www.open-open.com/19.htm" target="_blank">http://www.open-open.com/19.htm</a><wbr /><br> <br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open3219.htm" target="_blank">Openreports</a><wbr />   点击次数：14295OpenReports提供基于web的灵活报表解决方案，通过浏览器自动生成动态PDF,XLS,HTMLCSV和Chart报表。利用到的开源技术有Hibernate,Veloctiy,Webwork。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open8319.htm" target="_blank">JFreeChart</a><wbr />   点击次数：27611JFreeChart它主要是用来制作各种各样的图表，这些图表包括：饼图、柱状图(普通柱状图以及堆栈柱状图)、线图、区域图、分布图、混合图、甘特图以及一些仪表盘等等。<br><wbr /><a href="http://www.open-open.com/image/smallchart.png" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/smallchart.png" /></a><wbr /><br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open8419.htm" target="_blank">JasperReports</a><wbr />   点击次数：20163JasperReports是一个基于Java的开源报表工具，它可以在Java环境下像其它IDE报表工具一样来制作报表。JasperReports支持PDF、HTML、XLS、CSV和XML文件输出格式。JasperReports是当前Java开发者最常用的报表工具。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open9719.htm" target="_blank">JFreeReport </a><wbr />  点击次数：13368JFreeReport是一个用来生成报表的Java类库。它为Java应用程序提供一个灵活的打印功能并支持输出到打印机和PDF, Excel, HTML和XHTML, PlainText, XML和CSV文件中。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open13419.htm" target="_blank">jCharts</a><wbr />   点击次数：9575jCharts是一个100％基于Java的制图工具，它可以输出很多种图表。这个包是通过Servlets显示图表理想选择。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open13519.htm" target="_blank">Cewolf</a><wbr />   点击次数：10004Cewolf可以在一个基于Servlet/JSP的Web应用程序内部使用，以在Web页中嵌入各种复杂的图形图表(如，直方图、饼图、棒图等等)。它提供了一个功能完备的标签库来定义图表的所有属性(颜色、笔画、图例等)，这样嵌入了图表的JSP就不用使用任何Java代码。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open13619.htm" target="_blank">JOpenChart</a><wbr />   点击次数：7903JOpenChart库和工具包提供了创建不同的图表的方法，包括饼图、直方图、和自绘图。进一步，它包含了将图表嵌入到Swing 或Web应用程序中的组件。这个库的Renderer Interface API可以方便地为不同种类的图表增加新的绘制。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open13719.htm" target="_blank">iReport</a><wbr />   点击次数：14234iReport是为JasperReports设计的强大的，直观的，易于使用的可视化报表设计器采用纯Java开发。这个工具允许用户可视化编辑包含charts,图片,子报表等的复杂报表。iReport 还集成了<a href="http://www.jfree.org/jfreechart/index.html" target="_blank">JFreeChart</a><wbr />图表制作包。允许用户可视化地编辑XML JasperDesign文件。用于打印的数据可以通过多种方式获取包括：JDBC, TableModels, JavaBeans, XML,Hibernate(支持HQL查询语言), CSV等。它支持多种输出格式包括：PDF,RTF,XML,XLS,CSV,HTM。<br><wbr /><a href="http://www.open-open.com/image/ir2shot10.jpg" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/ir2shot10.jpg" /></a><wbr /><br><wbr /><a href="http://www.open-open.com/image/shot2mini.jpg" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/shot2mini.jpg" /></a><wbr /><br><br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open13819.htm" target="_blank">Chart2D </a><wbr />  点击次数：8071Chart2D - 一个直观显示数据流量的2维图表（pie,线，垂直条，水平条，分散条（点），合并和覆盖图。有JComponent 和 BufferedImage类图表。 <br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open13919.htm" target="_blank">DataVision</a><wbr />   点击次数：8195DataVision是一个用Java编写的类似于Crystal Reports的报表工具。它支持多种数据源(JDBC, 文本文件) ，输出格式有HTML, XML, PDF, LaTeX, 逗号或tab分隔的数据文件, 和DocBook。它让你用一个支持拖放操作的GUI设计报表，报表描述存储为XML。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open14019.htm" target="_blank">JCCKit</a><wbr />   点击次数：7803JCCKit是一个很小(&lt; 100Kb)而且灵活的图形报表制作框架。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open38019.htm" target="_blank">JSynoptic</a><wbr />   点击次数：7593介绍一个很错不的 Java 图表制作工具 JSynoptic，它把简单数据源（data source）根据你的需要自动生成各种类型的图表，比如柱状图、饼状图。这个工具核心是 JFreeChart，如果你仅仅需要一些统计图表，而不是做开发，那么这个工具将非常适合你。 <br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open55919.htm" target="_blank">Eclipse BIRT</a><wbr />   点击次数：11889BIRT是一个Eclipse-based开放源代码报表系统。它主要是用在基于Java与J2EE的Web应用程序上。BIRT主要由两部分组成：一个是基于Eclipse的报表设计和一个可以加到你应用服务的运行期组件。BIRT同时也提供一个图形报表制作引擎。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open58719.htm" target="_blank">JERT</a><wbr />   点击次数：9329JERT是一个开放源代码的(<a href="http://www.hibernate.org.cn/" target="_blank">Java视线</a><wbr />开源项目)，基于web的，数据库报表工具，它能够让你不需要编程而能创建各种灵活的报表。（需要了解一定的SQL知识) 。JERT使用到许多优秀的开源项目Hibernate/Spring/Webwork/Sitemesh/FreeMarker。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open61019.htm" target="_blank">ARTART</a><wbr />   点击次数：7715ART是一个轻量级的，基于web的报表引擎。定制容易，支持图形报表，支持通过插件把结果导出为各种格式。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open61119.htm" target="_blank">JChart2d</a><wbr />   点击次数：7315JChart2d是为那些需要精确的图形报表但可以不注重图形报表漂亮的工程任务所提供的一种工具。它有着简洁,可扩展的API和丰富的文档。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open73619.htm" target="_blank">JasperAssistant</a><wbr />   点击次数：8147JasperAssistant是一个JasperReports的可视化报表设计器，一个受欢迎的报表引擎。它构建在Eclipse的插件体系之上，它的主要目的是通过一个直观的图形界面来帮助你开发JasperReports报表定义文件。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open77019.htm" target="_blank">ObjectVisualizer</a><wbr />   点击次数：7416ObjectVisualizer是一个开源的商业化智能工具,属于OpenReports项目的一部分.它依赖于对象持久性技术(Hibernate,JDO,与Cayenne)用来对Object映射的数据进行查询,制表和制图.<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open109319.htm" target="_blank">Fourfive</a><wbr />   点击次数：10133Fourfive是一个领先的开源Web报表解决方案，使用XML作为它的配置文件。支持集群、负载平衡、动态发布、PDF, Excel, LDAP,图表、过滤器、排序、布局定制、门户、JasperReports、Velocity模板、兼容Internet Explorer, Netscape, Mozilla, Opera。<br><wbr /><a href="http://www.open-open.com/image/pareto_sample.gif" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/pareto_sample.gif" /></a><wbr /><br><br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open110719.htm" target="_blank">JooReports</a><wbr />   点击次数：7734JooReports是一个基于OpenOffice.org利用Java创建Office文档与报表的解决方案.模板可利用word处理器进行设计.生成的文档可以是PDF,Word和其它格式.数据源包括POJOs与XML.<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open128219.htm" target="_blank">Pentaho</a><wbr />   点击次数：9148Pentaho商业智能项目提供企业级报表制作,分析,数据挖掘与工作流的功能.这个软件提供灵活的部署选项以使它可作为嵌入式组件来使用,或作为定制BI应用程序的解决方案或作为一个完全脱离容器，完整的BI平台。Pentaho包括Eclipse BIRT,JasperReports,Mondrian,JPivot,调度(scheduling),web服务,商业规则。<br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open138919.htm" target="_blank">JMagallanes</a><wbr />   点击次数：7982开源项目JMagallanes是一个用Java/J2EE开发的Olap和动态报表应用程序。JMagallanes结合了静态报表(基于JasperReports)，Swing pivot表格(用于OLAP分析),和图表(基于JFreeChart)。它可从多种数据源(如：SQL,Excel,XML和其它)读取数据并可生成多种输出如：PDF,XML,应用程序特殊文件用于将来报表的脱机查看。<br><wbr /><a href="http://www.open-open.com/image/screenshot_thumb.jpg" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/screenshot_thumb.jpg" /></a><wbr /><wbr /><a href="http://www.open-open.com/image/screenshot_thumb1.jpg" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/screenshot_thumb1.jpg" /></a><wbr /><wbr /><a href="http://www.open-open.com/image/screenshot_thumb2.jpg" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/screenshot_thumb2.jpg" /></a><wbr /><wbr /><a href="http://www.open-open.com/image/screenshot_thumb3.jpg" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/screenshot_thumb3.jpg" /></a><wbr /><br><wbr /><a href="http://www.open-open.com/image/screenshot_thumb4.jpg" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/screenshot_thumb4.jpg" /></a><wbr /><br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open147819.htm" target="_blank">JR Free Web Chart Component</a><wbr />   点击次数：7607JR Free Web Chart Component提供了三种开源的Web Chart组件：FreeWebBarChart4J、FreeWebLineChart4J、FreeWebPieChart4J。这些组件支持3D,支持GIF,JPEG,PNG和SVG等多种图片格式，易于使用。可以在applet中使用,也可以在servlet/JSP中使用。在其主页上还提供了许多可以免费下载的文档，电子书籍，源代码。其中有一些比较常用的开源组件和框架的开发指南如：JFreeChart,JasperReports,Hibernate,Struts,Spring等。<br><wbr /><a href="http://www.open-open.com/image/pie3d.gif" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/pie3d.gif" /></a><wbr /><br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open149419.htm" target="_blank">ReportJet</a><wbr />   点击次数：8118ReportJet是一个基于Java的商业智能和报表系统。ReportJet Designer构建在Eclipse胖客户端平台(RCP)之上，为快速，简单地设计复杂的报表模板提供一个友好的用户界面。<br><wbr /><a href="http://www.open-open.com/image/ReportJet.gif" target="_blank"><img style="border:0;" src="http://www.open-open.com/image/ReportJet.gif" /></a><wbr /><br><wbr /><a href="http://www.open-open.com/image/item.gif" target="_blank"><img style="width:13px;height:14px;border:0;" src="http://www.open-open.com/image/item.gif" /></a><wbr /> <a href="http://www.open-open.com/open178219.htm" target="_blank">Carte</a><wbr />   点击次数：6480Carte是一个报表模板引擎能够生成Text(包括HTML与XML)与PDF格式的报表。 所需要的第三方类库包括： <a href="http://www.informatica.info/projects/css/" target="_blank">Carte CSS</a><wbr />,DOM CSS Java类库. <a href="http://www.lowagie.com/iText/" target="_blank">iText</a><wbr />,生成PDF格式的Java类库. <a href="http://jcharts.sourceforge.net/" target="_blank">jCharts-基于Java的制图工具包。</a><wbr /> <a href="http://www.informatica.info/projects/jclf/" target="_blank">JCLF</a><wbr />,一组Java常用Utilitie. <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1190249644#comment</comments>
<qz:effect>513</qz:effect>
<pubDate>Thu, 20 Sep 2007 00:54:04 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1190249644</guid>
</item>

<item>
<title><![CDATA[jsp+ajax自动刷新实例(ajax)]]></title>
<link>http://78258520.qzone.qq.com/blog/1190249497</link>
<description><![CDATA[jsp+ajax自动刷新实例(ajax)<a href="http://hi.baidu.com/05043/blog/item/55579a51ac81142643a75b76.html" target="_blank">http://hi.baidu.com/05043/blog/item/55579a51ac81142643a75b76.html</a><wbr /><br>一、处理ajax请求的jsp文件：auto.jsp<br>&lt;%@ page c %&gt;<br>&lt;%<br>//设置输出信息的格式及字符集 <br>response.setContentType(&quot;text/xml; charset=UTF-8&quot;);<br>response.setHeader(&quot;Cache-Control&quot;,&quot;no-cache&quot;);<br>out.println(&quot;&lt;response&gt;&quot;); <br><br>for(int i=0;i&lt;2;i++){<br>out.println(&quot;&lt;name&gt;&quot;+(int)(Math.random()*10)+&quot;型笔记本&lt;/name&gt;&quot;);<br>out.println(&quot;&lt;count&gt;&quot; +(int)(Math.random()*100)+ &quot;&lt;/count&gt;&quot;);<br>}<br>out.println(&quot;&lt;/response&gt;&quot;);<br>out.close();<br>%&gt; <br>二、发送ajax请求的html文件：autoRefresh.html<br>&lt;head&gt;<br>&lt;META http-equiv=Content-Type c&gt;<br>&lt;/head&gt;<br>&lt;script language=&quot;javascript&quot;&gt;<br><br>var XMLHttpReq;   //创建XMLHttpRequest对象               function createXMLHttpRequest() {   if(window.XMLHttpRequest) { //Mozilla 浏览器    XMLHttpReq = new XMLHttpRequest();   }   else if (window.ActiveXObject) { // IE浏览器    try {     XMLHttpReq = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);    } catch (e) {     try {      XMLHttpReq = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);     } catch (e) {}    }   } } //发送请求函数 function sendRequest() {   createXMLHttpRequest();          var url = &quot;auto.jsp&quot;;   XMLHttpReq.open(&quot;GET&quot;, url, true);   XMLHttpReq.onreadystatechange = processResponse;//指定响应函数   XMLHttpReq.send(null);    // 发送请求 } // 处理返回信息函数      function processResponse() {       if (XMLHttpReq.readyState == 4) { // 判断对象状态           if (XMLHttpReq.status == 200) { // 信息已经成功返回，开始处理信息     DisplayHot();     setTimeout(&quot;sendRequest()&quot;, 1000);              } else { //页面不正常                  window.alert(&quot;您所请求的页面有异常。&quot;);              }          }      }      function DisplayHot() {       var name = XMLHttpReq.responseXML.getElementsByTagName(&quot;name&quot;)[0].firstChild.nodeValue;       var count = XMLHttpReq.responseXML.getElementsByTagName(&quot;count&quot;)[0].firstChild.nodeValue;   document.getElementById(&quot;product&quot;).innerHTML = name;    document.getElementById(&quot;count&quot;).innerHTML = count;  }<br><br>&lt;/script&gt; &lt;body onload =sendRequest()&gt;<br>&lt;table style=&quot;BORDER-COLLAPSE: collapse&quot; borderColor=#111111 cellSpacing=0 cellPadding=0 width=200      bgColor=#f5efe7 border=0&gt;<br><br>&lt;TR&gt;<br>     &lt;TD align=middle bgColor=#dbc2b0 height=19 colspan=&quot;2&quot;&gt;&lt;B&gt;正在热卖的笔记本&lt;/B&gt; &lt;/TD&gt;<br>&lt;/TR&gt;<br>&lt;tr&gt;<br>     &lt;td height=&quot;20&quot;&gt; 型号：&lt;/td&gt;<br>     &lt;td height=&quot;20&quot; id=&quot;product&quot;&gt; &lt;/td&gt;<br>&lt;/tr&gt;<br>&lt;tr&gt;<br>     &lt;td height=&quot;20&quot;&gt; 销售数量：&lt;/td&gt;<br>     &lt;td height=&quot;20&quot; id=&quot;count&quot;&gt; &lt;/td&gt;<br>&lt;/tr&gt;<br>&lt;/body&gt; <br>&lt;/table&gt; <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1190249497#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Thu, 20 Sep 2007 00:51:37 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1190249497</guid>
</item>

<item>
<title><![CDATA[AJAX for Java简单表数据查询实例]]></title>
<link>http://78258520.qzone.qq.com/blog/1190249287</link>
<description><![CDATA[<a href="http://146133.blog.51cto.com/136133/22940" target="_blank">http://146133.blog.51cto.com/136133/22940</a><wbr /><br><div style="text-align:center;"><span style="font-family:'Times';line-height:1.8em;">AJAX for Java</span><wbr /></span><wbr />简单表数据查询实例</span><wbr /></span><wbr /></div><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">AJAX WebShop 3</span><wbr />对<span style="font-family:'Times';line-height:1.8em;">Java</span><wbr />开发具有良好的支持，同时也提供了各种层次的后台服务开发接口，本系列文章对<span style="font-family:'Times';line-height:1.8em;">AJAX for Java</span><wbr />的数据库应用编程方式进行全面介绍。</span><wbr /><br><br><span style="font-size:16px;line-height:1.8em;">一<span style="font-family:'Times';line-height:1.8em;">.</span><wbr /></span><wbr />数据表说明</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;">例子采用了<span style="font-family:'Times';line-height:1.8em;">Access</span><wbr />数据库，当然你也可以使用<span style="font-family:'Times';line-height:1.8em;">mysql </span><wbr />或其他类型数据库，数据库名称为：<span style="font-family:'Times';line-height:1.8em;">demo.mdb</span><wbr />，表名为<span style="font-family:'Times';line-height:1.8em;">product</span><wbr />，创建字段分别是<span style="font-family:'Times';line-height:1.8em;">PRODUCT_ID, PRODUCT_NAME, PRODUCT_PRICE, PRODUCT_AREA</span><wbr />。</span><wbr /><br><br><span style="font-size:16px;line-height:1.8em;">二<span style="font-family:'Times';line-height:1.8em;">.</span><wbr /></span><wbr />实现数据查询</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;">首先启动<span style="font-family:'Times';line-height:1.8em;">AJAX WebShop 3</span><wbr />，在<span style="font-family:'Times';line-height:1.8em;">File</span><wbr />中选择“<span style="font-family:'Times';line-height:1.8em;">New Project</span><wbr />”建立新工程。</span><wbr /><br><br><br><span style="font-size:16px;line-height:1.8em;">在弹出的<span style="font-family:'Times';line-height:1.8em;">New Project</span><wbr />对话框中设置<span style="font-family:'Times';line-height:1.8em;">projectname </span><wbr />和<span style="font-family:'Times';line-height:1.8em;">web server</span><wbr />本例中设置<span style="font-family:'Times';line-height:1.8em;">projectname</span><wbr />为：<span style="font-family:'Times';line-height:1.8em;">java_example</span><wbr />和设置<span style="font-family:'Times';line-height:1.8em;">web server</span><wbr />为：<span style="font-family:'Times';line-height:1.8em;">Java</span><wbr />。如果要修改工程路径，请在<span style="font-family:'Times';line-height:1.8em;">Directory</span><wbr />中设置要存放的路径。</span><wbr /><br><br><br><span style="font-size:16px;line-height:1.8em;">首先我们要实现后台的数据库访问服务类，实现<span style="font-family:'Times';line-height:1.8em;">Java</span><wbr />后台服务类的方法有几种，但都是使用<span style="font-family:'Times';line-height:1.8em;">XmlDataSet</span><wbr />类，在<span style="font-family:'Times';line-height:1.8em;">3.0</span><wbr />版本之前是使用<span style="font-family:'Times';line-height:1.8em;">XmlRequest</span><wbr />和<span style="font-family:'Times';line-height:1.8em;">XmlPost</span><wbr />类，而<span style="font-family:'Times';line-height:1.8em;">XmlDataSet</span><wbr />是这两个功能的集成，并提供了更简单易用的方法：</span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-weight:bold"><wbr />方法<span style="font-family:'Times';line-height:1.8em;">A:</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />通过<span style="font-family:'Times';line-height:1.8em;">WebShop</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />的向导产生基于<span style="font-family:'Times';line-height:1.8em;">BusinessObjectBean</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />的类代码框架，然后在此基础上修改<span style="font-family:'Times';line-height:1.8em;">query_XML</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />和<span style="font-family:'Times';line-height:1.8em;">update_XML</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />方法</span><wbr /></span><wbr /><br><br><span style="font-size:16px;line-height:1.8em;">设置好<span style="font-family:'Times';line-height:1.8em;">New Project</span><wbr />后，再打开“<span style="font-family:'Times';line-height:1.8em;">File</span><wbr />”选择“<span style="font-family:'Times';line-height:1.8em;">New .Java Service</span><wbr />”，在弹出的对话框内目录输入包名：<span style="font-family:'Times';line-height:1.8em;">demo</span><wbr />，设置<span style="font-family:'Times';line-height:1.8em;">”Class Name”</span><wbr />为：<span style="font-family:'Times';line-height:1.8em;">Simple</span><wbr />，点击“<span style="font-family:'Times';line-height:1.8em;">OK</span><wbr />“后，向导将按默认模板生成<span style="font-family:'Times';line-height:1.8em;">Java</span><wbr />单表数据读取和数据提交的代码，修改代码中的数据库连接串、表名就可以了。</span><wbr /><br><br><br><span style="font-size:16px;line-height:1.8em;"><span style="font-weight:bold"><wbr />方法<span style="font-family:'Times';line-height:1.8em;">B</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />：</span><wbr /><span style="font-weight:bold"><wbr />使用其他<span style="font-family:'Times';line-height:1.8em;">Java</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />开发工具，建立基于<span style="font-family:'Times';line-height:1.8em;">BusinessObjectBean</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />的类并覆盖<span style="font-family:'Times';line-height:1.8em;">query_XML</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />和<span style="font-family:'Times';line-height:1.8em;">update_XML</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />方法。</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;">方法<span style="font-family:'Times';line-height:1.8em;">A</span><wbr />和<span style="font-family:'Times';line-height:1.8em;">B</span><wbr />需要使用两个<span style="font-family:'Times';line-height:1.8em;">Servlet</span><wbr />：<span style="font-family:'Times';line-height:1.8em;">Query.class</span><wbr />和<span style="font-family:'Times';line-height:1.8em;">Update.class</span><wbr />，这两个<span style="font-family:'Times';line-height:1.8em;">Servlet</span><wbr />在<span style="font-family:'Times';line-height:1.8em;">web.xml</span><wbr />中有配置。</span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-weight:bold"><wbr />方法<span style="font-family:'Times';line-height:1.8em;">C</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />：</span><wbr /><span style="font-weight:bold"><wbr />使用其他<span style="font-family:'Times';line-height:1.8em;">Java</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />开发工具，分别建立数据读取和数据提交的<span style="font-family:'Times';line-height:1.8em;">servlet</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />或<span style="font-family:'Times';line-height:1.8em;">jsp</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />，当然也可以建立您自己的框架与控制机制，比如用您的<span style="font-family:'Times';line-height:1.8em;">servlet</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />控制调用相关的<span style="font-family:'Times';line-height:1.8em;">JavaBean</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />，在<span style="font-family:'Times';line-height:1.8em;">JavaBean</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />中实现数据读取和数据提交。此种方法也可以与现有的流行框架很好地融合。</span><wbr /></span><wbr /><br><span style="font-weight:bold"><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-weight:bold"><wbr />不管采用以上何种方法主要涉及<span style="font-family:'Times';line-height:1.8em;">XmlDataSet</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />类，常用的属性：<span style="font-family:'Times';line-height:1.8em;">maxRows</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">recNo</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />，常用的方法：<span style="font-family:'Times';line-height:1.8em;">open</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">getParam</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">fillFields</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">fillData</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">fillRow</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">addField</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">append</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">setValue</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">setRecordCount</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">getXml</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、<span style="font-family:'Times';line-height:1.8em;">setError</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />，详细请参考帮助文档。</span><wbr /></span><wbr /><br><br><span style="font-weight:bold"><wbr /><span style="font-size:16px;line-height:1.8em;">简单读取数据的几种实现方法：</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-weight:bold"><wbr /><span style="font-family:'Times';line-height:1.8em;">JavaBean</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />数据读取方法</span><wbr /></span><wbr /><br><br><span style="font-size:16px;font-family:'Times';line-height:1.8em;">import joyistar.eip.bs.*;</span><wbr /><br><span style="font-size:16px;font-family:'Times';line-height:1.8em;">import joyistar.eip.vo.*;</span><wbr /><br><span style="font-size:16px;font-family:'Times';line-height:1.8em;">import java.sql.*;</span><wbr /><br><br><span style="font-size:16px;font-family:'Times';line-height:1.8em;">public class Simple extends BusinessObjectBean {</span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String drivers   = &quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String url       = &quot;jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=database/demo.mdb&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String tablename = &quot;product&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String username  = &quot;&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String password  = &quot;&quot;;</span><wbr /></span><wbr /><br><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    public Simple() {</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    }</span><wbr /></span><wbr /><br><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    public joyistar.eip.vo.XmlDataSet query_XML(joyistar.eip.vo.XmlDataSet xmlDataSet) throws Exception {</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        Connection conn = null;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        String sql      = &quot;&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        ResultSet rs    = null;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        Statement stmt  = null;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        try{</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            System.setProperty(&quot;jdbc.drivers&quot;, drivers);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            conn = DriverManager.getConnection(url, username, password);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            sql  = &quot;select * from &quot; + tablename;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            rs   = stmt.executeQuery(sql);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            rs.last();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            xmlDataSet.setRecordCount(rs.getRow());</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">                     xmlDataSet.fillFields(rs);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">                     xmlDataSet.fillData(rs);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">         } </span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">               catch(Exception e) {</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            xmlDataSet.error = e.getMessage();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">               e.printStackTrace();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        } </span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">              finally {</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            if(rs != null)</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            rs.close();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            if(stmt != null)</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            stmt.close();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            if(conn != null)</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            conn.close();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        }  </span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        return xmlDataSet;  </span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    }    </span><wbr /></span><wbr /><br><span style="font-weight:bold"><wbr /></span><wbr /><br><span style="font-weight:bold"><wbr /><span style="font-size:16px;line-height:1.8em;">ＪＳＰ数据读取使用方法</span><wbr /></span><wbr /><br><span style="font-size:16px;font-family:'Times';line-height:1.8em;">&lt;%@ page c %&gt;</span><wbr /><br><span style="font-size:16px;font-family:'Times';line-height:1.8em;">&lt;%@ page import=&quot;joyistar.eip.vo.*&quot; %&gt;</span><wbr /><br><span style="font-size:16px;font-family:'Times';line-height:1.8em;">&lt;%@ page import=&quot;java.sql.*&quot; %&gt;</span><wbr /><br><span style="font-size:16px;font-family:'Times';line-height:1.8em;">&lt;%</span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String drivers   = &quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String url       = &quot;jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=database/demo.mdb&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String tablename = &quot;product&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String username  = &quot;&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String password  = &quot;&quot;;        </span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">       Connection conn  = null;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    String sql       = &quot;&quot;;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    ResultSet rs     = null;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    Statement stmt   = null;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    XmlDataSet xmlDataSet = new XmlRequest();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    try{</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">           xmlDataSet.open(request);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        System.setProperty(&quot;jdbc.drivers&quot;, drivers);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        conn = DriverManager.getConnection(url, username, password);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        sql  = &quot;select * from &quot; + tablename;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        rs   = stmt.executeQuery(sql);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        rs.last();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        xmlDataSet.setRecordCount(rs.getRow());</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">              xmlDataSet.fillFields(rs);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">              xmlDataSet.fillData(rs);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">              out.println(xmlDataSet.getXml());</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">              out.flush();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    } </span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">       catch(Exception e) {</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        xmlDataSet.error = e.getMessage();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">              out.println(xmlDataSet.getXml());</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">              out.flush();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">           e.printStackTrace();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    } </span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">       finally {</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        if(rs != null)</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        rs.close();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        if(stmt != null)</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">                     stmt.close();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        if(conn != null)</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            conn.close();</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">    }  </span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">%&gt;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;">在这里需要说明的是，如果带有参数的查询，需要加入类似以下取参数的代码：</span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        Param param1     = xmlDataSet.getParam(&quot;SALE_ID&quot;);</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        if(param1!=null) {</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">            sql += &quot; where SALE_ID=&quot;+param1.value;</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">        }</span><wbr /></span><wbr /><br><br><span style="font-size:16px;line-height:1.8em;">如果是<span style="font-family:'Times';line-height:1.8em;">JavaBean</span><wbr />，需要使用<span style="font-family:'Times';line-height:1.8em;">Run-&gt;Build</span><wbr />编译生成类文件（相关的路径在工程属性中可以查看），后台数据访问类建立好后，在“<span style="font-family:'Times';line-height:1.8em;">File</span><wbr />”中选择“<span style="font-family:'Times';line-height:1.8em;">New Page</span><wbr />”打开“<span style="font-family:'Times';line-height:1.8em;">New Page</span><wbr />”对话框在“<span style="font-family:'Times';line-height:1.8em;">File Name</span><wbr />”中设置页面名称，如本例“<span style="font-family:'Times';line-height:1.8em;">simple.htm</span><wbr />”点击<span style="font-family:'Times';line-height:1.8em;">ok</span><wbr />完成设置。</span><wbr /><br><br><br><span style="font-size:16px;line-height:1.8em;">在<span style="font-family:'Times';line-height:1.8em;">webshop</span><wbr />的元件选项板“<span style="font-family:'Times';line-height:1.8em;">Data Access </span><wbr />”，“<span style="font-family:'Times';line-height:1.8em;">DBControl</span><wbr />”中，拖拉向表单加入<span style="font-family:'Times';line-height:1.8em;">DataSet</span><wbr />和数据感应控件<span style="font-family:'Times';line-height:1.8em;">DBNavigator</span><wbr />、<span style="font-family:'Times';line-height:1.8em;">DBEdit</span><wbr />、<span style="font-family:'Times';line-height:1.8em;">DBGrid</span><wbr />等，简单地可视化拖拉建立界面，点击组件，会在右侧出现相应属性。</span><wbr /><br><span style="font-size:16px;line-height:1.8em;"><span style="font-weight:bold"><wbr /></span><wbr /><span style="font-weight:bold"><wbr />注意：<span style="font-family:'Times';line-height:1.8em;">AJAX</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />　<span style="font-family:'Times';line-height:1.8em;">for Java</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />开发中<span style="font-family:'Times';line-height:1.8em;">DataSet</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />的服务路径设置有几种方法，分别对应以上几种后台的开发方式，一种是设置<span style="font-family:'Times';line-height:1.8em;">DataSource</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />的类名，另一种是设置<span style="font-family:'Times';line-height:1.8em;">OpenURL</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />和<span style="font-family:'Times';line-height:1.8em;">UpdateURL</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />。如果设置了<span style="font-family:'Times';line-height:1.8em;">DataSource</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />将系统优先采用这种方式。<span style="font-family:'Times';line-height:1.8em;">DataSource</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />是用于<span style="font-family:'Times';line-height:1.8em;">JavaBean</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />的方式，而　<span style="font-family:'Times';line-height:1.8em;">OpenURL</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />和<span style="font-family:'Times';line-height:1.8em;">UpdateURL</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />适用于您的<span style="font-family:'Times';line-height:1.8em;">JSP</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />、Ｓ<span style="font-family:'Times';line-height:1.8em;">ervlet</span><wbr /></span><wbr /><span style="font-weight:bold"><wbr />或框架。</span><wbr /></span><wbr /><br><span style="font-size:16px;line-height:1.8em;">选择<span style="font-family:'Times';line-height:1.8em;">DataSet1</span><wbr />，在“<span style="font-family:'Times';line-height:1.8em;">DataSource</span><wbr />”属性中添加<span style="font-family:'Times';line-height:1.8em;">Java Service</span><wbr />类路径或在“<span style="font-family:'Times';line-height:1.8em;">OpenURL</span><wbr />”属性中添加<span style="font-family:'Times';line-height:1.8em;">Service</span><wbr />的<span style="font-family:'Times';line-height:1.8em;">JSP</span><wbr />（<span style="font-family:'Times';line-height:1.8em;">Servlet</span><wbr />），这里设置<span style="font-family:'Times';line-height:1.8em;">DataSource</span><wbr />为“<span style="font-family:'Times';line-height:1.8em;">demo/Simple</span><wbr />”，如果是使用<span style="font-family:'Times';line-height:1.8em;">JSP</span><wbr />（<span style="font-family:'Times';line-height:1.8em;">Servlet</span><wbr />），这里可能是<span style="font-family:'Times';line-height:1.8em;">demo/simple_query.jsp</span><wbr />。</span><wbr /><br><span style="font-size:16px;line-height:1.8em;">打开<span style="font-family:'Times';line-height:1.8em;">WebShop</span><wbr />中的“<span style="font-family:'Times';line-height:1.8em;">Run</span><wbr />”启动<span style="font-family:'Times';line-height:1.8em;">”Start WebServer”</span><wbr />服务，内嵌的<span style="font-family:'Times';line-height:1.8em;">Tomcat</span><wbr />将启动。</span><wbr /><br><span style="font-size:16px;line-height:1.8em;">成功启动“<span style="font-family:'Times';line-height:1.8em;">WebServer”</span><wbr />服务后，在<span style="font-family:'Times';line-height:1.8em;">DataSet1</span><wbr />的“<span style="font-family:'Times';line-height:1.8em;">Fields”</span><wbr />属性中添加数据字段，方法为点击右侧“<span style="font-family:'Times';line-height:1.8em;">…</span><wbr />”弹出<span style="font-family:'Times';line-height:1.8em;">Fields</span><wbr />对话框，在页面单击右键，在弹出选项中选择“<span style="font-family:'Times';line-height:1.8em;">Add Field</span><wbr />”在弹出的“<span style="font-family:'Times';line-height:1.8em;">Field List”</span><wbr />中点击<span style="font-family:'Times';line-height:1.8em;"> “Refresh”</span><wbr />会在列表中显示数据表“<span style="font-family:'Times';line-height:1.8em;">Product </span><wbr />”的字段名，全部选中后，点击“<span style="font-family:'Times';line-height:1.8em;">ok</span><wbr />”完成设置.</span><wbr /><br><br><br><br><span style="font-size:16px;line-height:1.8em;">设置好数据连接后，“<span style="font-family:'Times';line-height:1.8em;">DataSet1</span><wbr />的“<span style="font-family:'Times';line-height:1.8em;">Active”</span><wbr />属性设置为“<span style="font-family:'Times';line-height:1.8em;">true</span><wbr />”如图；</span><wbr /><br><span style="font-size:16px;line-height:1.8em;">　　同时选择<span style="font-family:'Times';line-height:1.8em;">DBGrid1</span><wbr />、<span style="font-family:'Times';line-height:1.8em;">DBNavigator</span><wbr />、<span style="font-family:'Times';line-height:1.8em;">DBEdit</span><wbr />等界面对象，在<span style="font-family:'Times';line-height:1.8em;">DataSet</span><wbr />属性中选择数据源　“<span style="font-family:'Times';line-height:1.8em;">DataSet1”</span><wbr />。完成数据库连接；另外，<span style="font-family:'Times';line-height:1.8em;">DBEdit</span><wbr />需要选择设置<span style="font-family:'Times';line-height:1.8em;">DataField</span><wbr />属性，指定要绑定的字段，点击“<span style="font-family:'Times';line-height:1.8em;">Run</span><wbr />”查看运行效果。</span><wbr /><br><br><br><span style="font-size:16px;line-height:1.8em;">这里实现的是一个简单的表数据读取，后续的文章中我将介绍表数据提交、主从表及更高级的<span style="font-family:'Times';line-height:1.8em;">AJAX</span><wbr />数据库应用编程。</span><wbr /><br><a href="http://146133.blog.51cto.com/136133/22940" target="_blank"><span style="color:#0008ec;line-height:1.8em;">本文出自 51CTO.COM技术博客</span><wbr /></a><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1190249287#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Thu, 20 Sep 2007 00:48:07 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1190249287</guid>
</item>

<item>
<title><![CDATA[如何读取Excel数据并导入DB2数据库]]></title>
<link>http://78258520.qzone.qq.com/blog/1190249229</link>
<description><![CDATA[<a href="http://www.builder.com.cn/2007/0904/489535.shtml" target="_blank">http://www.builder.com.cn/2007/0904/489535.shtml</a><wbr /><br> <br>最近项目需要读取Excel，将数据导入数据库保存，最终可以用报表读取数据库并显示，比较简单。查了一下两者的资料，觉的也无所谓，我需要的功能比较简单，只要能读取Excel数据就行，最后决定使用POI，比较信任apache,使用果然很简单，上网找了个源码，Copy过来稍微改改就能用了。 <br>下面附的代码是一个Demo，功能有两个：一是POI读取Excel，二是<a href="http://www.ibm.com/developerworks/cn/db2/zones/db2ii/index_old.html?S_TACT=105AGX52&amp;S_CMP=w-cto" target="_blank">DB2</a><wbr />数据库的连接和SQL执行。 <br>import Java.io.FileInputStream;<br><br>import java.io.IOException;<br><br>import java.sql.Connection;<br><br>import java.sql.DriverManager;<br><br>import java.sql.SQLException;<br><br>import java.sql.Statement;<br>import org.apache.poi.hssf.usermodel.HSSFCell;<br><br>import org.apache.poi.hssf.usermodel.HSSFRow;<br><br>import org.apache.poi.hssf.usermodel.HSSFSheet;<br><br>import org.apache.poi.hssf.usermodel.HSSFWorkbook;<br><br>import org.apache.poi.poifs.filesystem.POIFSFileSystem;<br>public class POITest {<br><br>private static Connection conn = null;<br><br>private static Statement stmt = null;<br><br>private static boolean connect<a href="http://www.ibm.com/developerworks/cn/db2/zones/db2ii/index_old.html?S_TACT=105AGX52&amp;S_CMP=w-cto" target="_blank">DB2</a><wbr />() {<br>String url = &quot;&quot;;<br><br>String username = &quot;username&quot;;<br><br>String password = &quot;password&quot;;<br>//加载驱动程序以连接数据库<br><br>try {<br><br>//添加类库驱动包db2jcc.jar和db2jcc_license_cu.jar<br><br>Class.forName(&quot;com.ibm.db2.jcc.<a href="http://www.ibm.com/developerworks/cn/db2/zones/db2ii/index_old.html?S_TACT=105AGX52&amp;S_CMP=w-cto" target="_blank">DB2</a><wbr />Driver&quot;);<br><br>url = &quot;JDBC:db2://192.168.0.1:50000/dbname&quot;;<br><br>//添加类库驱动包db2java.jar<br><br>//Class.forName(&quot;com.ibm.db2.jdbc.app.<a href="http://www.ibm.com/developerworks/cn/db2/zones/db2ii/index_old.html?S_TACT=105AGX52&amp;S_CMP=w-cto" target="_blank">DB2</a><wbr />Driver&quot;).newInstance();<br><br>//url = &quot;jdbc:db2:njtcdata&quot;;<br><br>conn = DriverManager.getConnection(url, username, password);<br><br>stmt = conn.createStatement();<br><br>}<br><br>//捕获加载驱动程序异常<br><br>catch (ClassNotFoundException cnfex) {<br><br>System.err.println(&quot;装载JDBC驱动程序失败。&quot;);<br><br>cnfex.printStackTrace();<br><br>return false;<br><br>}<br><br>//捕获连接数据库异常<br><br>catch (SQLException sqlex) {<br><br>System.err.println(&quot;无法连接数据库&quot;);<br><br>sqlex.printStackTrace();<br><br>//System.exit(1); // terminate program<br><br>return false;<br><br>}<br><br>return true;<br><br>}<br>private static boolean readExcelTo<a href="http://www.ibm.com/developerworks/cn/db2/zones/db2ii/index_old.html?S_TACT=105AGX52&amp;S_CMP=w-cto" target="_blank">DB2</a><wbr />() {<br><br>POIFSFileSystem fs = null;<br><br>HSSFWorkbook wb = null;<br><br>try {<br><br>fs = new POIFSFileSystem(new FileInputStream(&quot;c:test.xls&quot;));<br><br>wb = new HSSFWorkbook(fs);<br><br>} catch (IOException e) {<br><br>e.printStackTrace();<br><br>return false;<br><br>}<br><br>HSSFSheet sheet = wb.getSheetAt(0);<br><br>HSSFRow row = null;<br><br>HSSFCell cell = null;<br><br>String name = &quot;&quot;;<br><br>int id = 0;<br><br>int rowNum, cellNum;<br><br>int i;<br><br>rowNum = sheet.getLastRowNum();<br><br>for (i = 0; i &lt;= rowNum; i++) {<br><br>row = sheet.getRow(i);<br><br>//cellNum = row.getLastCellNum();<br><br>cell = row.getCell((short) 0);<br><br>name = cell.getStringCellValue();<br><br>cell = row.getCell((short) 1);<br><br>id = (int) cell.getNumericCellValue();<br><br>String sql = &quot;insert into TEST(ID, NAME) values(&quot; + id + &quot;,'&quot; + name + &quot;')&quot;;<br><br>try  catch (SQLException e1) {<br><br>e1.printStackTrace();<br><br>return false;<br><br>}<br><br>}<br><br>return true;<br><br>}<br>public static void main(String[] args) {<br><br>if (connect<a href="http://www.ibm.com/developerworks/cn/db2/zones/db2ii/index_old.html?S_TACT=105AGX52&amp;S_CMP=w-cto" target="_blank">DB2</a><wbr />()==true){<br><br>if (readExcelTo<a href="http://www.ibm.com/developerworks/cn/db2/zones/db2ii/index_old.html?S_TACT=105AGX52&amp;S_CMP=w-cto" target="_blank">DB2</a><wbr />()==true)<br><br>System.out.println(&quot;数据导入成功&quot;);<br><br>else<br><br>System.out.println(&quot;数据导入失败&quot;);<br><br>}<br><br>else<br><br>}<br><br>} <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[78258520@qq.com(峰)]]></author>
<comments>http://78258520.qzone.qq.com/blog/1190249229#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Thu, 20 Sep 2007 00:47:09 GMT</pubDate>
<guid>http://78258520.qzone.qq.com/blog/1190249229</guid>
</item>

</channel>
</rss>

