﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-Java天地</title><link>http://www.blogjava.net/luyongfa/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 21 Apr 2026 06:32:59 GMT</lastBuildDate><pubDate>Tue, 21 Apr 2026 06:32:59 GMT</pubDate><ttl>60</ttl><item><title>SQL优化</title><link>http://www.blogjava.net/luyongfa/articles/429429.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Thu, 25 Feb 2016 06:24:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/articles/429429.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/429429.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/articles/429429.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/429429.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/429429.html</trackback:ping><description><![CDATA[<p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">1.对查询进行优化，要尽量避免全表扫描，首先应考虑在 where 及 order by 涉及的列上建立索引。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">2.应尽量避免在 where 子句中对字段进行 null 值判断，否则将导致引擎放弃使用索引而进行全表扫描，如：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num <span style="color: #0000ff;">is</span> <span style="color: #0000ff;">null</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><span style="color: #ff0000; background-color: #ffffff;">最好不要给数据库留NULL，尽可能的使用&nbsp;NOT NULL填充数据库.</span></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">备注、描述、评论之类的可以设置为&nbsp;NULL，其他的，最好不要使用NULL。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">不要以为&nbsp;NULL&nbsp;不需要空间，比如：char(100)&nbsp;型，在字段建立时，空间就固定了，&nbsp;不管是否插入值（NULL也包含在内），都是占用&nbsp;100个字符的空间的，如果是varchar这样的变长字段，&nbsp;null&nbsp;不占用空间。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">可以在num上设置默认值0，确保表中num列没有null值，然后这样查询：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num <span style="color: #808080;">=</span> <span style="font-weight: bold; color: #800000;">0</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">3.应尽量避免在 where 子句中使用 != 或 &lt;&gt; 操作符，否则将引擎放弃使用索引而进行全表扫描。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">4.应尽量避免在 where 子句中使用 or 来连接条件，<span style="color: #ff0000;">如果一个字段有索引，一个字段没有索引，将导致引擎放弃使用索引而进行全表扫描</span>，如：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num<span style="color: #808080;">=</span><span style="font-weight: bold; color: #800000;">10</span> <span style="color: #808080;">or</span> Name <span style="color: #808080;">=</span> <span style="color: #ff0000;">'</span><span style="color: #ff0000;">admin</span><span style="color: #ff0000;">'</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">可以这样查询：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num <span style="color: #808080;">= </span><span style="font-weight: bold; color: #800000;">10</span> <span style="color: #0000ff;">union</span> <span style="color: #808080;">all</span> <span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> Name <span style="color: #808080;">=</span> <span style="color: #ff0000;">'</span><span style="color: #ff0000;">admin</span><span style="color: #ff0000;">'</span></pre><p style="margin: 10px 0px; padding: 0px; text-indent: 28px; background-color: transparent;">5.in 和 not in 也要慎用，否则会导致全表扫描，如：</p></div><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num <span style="color: #808080;">in</span>(<span style="font-weight: bold; color: #800000;">1</span>,<span style="font-weight: bold; color: #800000;">2</span>,<span style="font-weight: bold; color: #800000;">3</span>)</pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><span style="color: #ff0000;">对于连续的数值，能用 between 就不要用 in 了</span>：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num <span style="color: #808080;">between</span> <span style="font-weight: bold; color: #800000;">1</span> <span style="color: #808080;">and</span> <span style="font-weight: bold; color: #800000;">3</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">很多时候用<span style="color: #ff0000;">&nbsp;exists 代替 in</span>&nbsp;是一个好的选择：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> num <span style="color: #0000ff;">from</span> a <span style="color: #0000ff;">where</span> num <span style="color: #808080;">in</span>(<span style="color: #0000ff;">select</span> num <span style="color: #0000ff;">from</span> b)</pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">用下面的语句替换：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> num <span style="color: #0000ff;">from</span> a <span style="color: #0000ff;">where</span> <span style="color: #808080;">exists</span>(<span style="color: #0000ff;">select</span> <span style="font-weight: bold; color: #800000;">1</span> <span style="color: #0000ff;">from</span> b <span style="color: #0000ff;">where</span> num<span style="color: #808080;">=</span>a.num)</pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">6.下面的查询也将导致全表扫描：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> name <span style="color: #808080;">like</span> &#8216;<span style="color: #808080;">%</span>abc<span style="color: #808080;">%</span>&#8217;</pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">若要提高效率，可以考虑全文检索。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">7.如果在 where 子句中使用参数，也会导致全表扫描。因为SQL只有在运行时才会解析局部变量，但优化程序不能将访问计划的选择推迟到运行时；它必须在编译时进行选择。然 而，如果在编译时建立访问计划，变量的值还是未知的，因而无法作为索引选择的输入项。如下面语句将进行全表扫描：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num <span style="color: #808080;">= </span><span style="color: #008000;">@num</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">可以改为强制查询使用索引：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">with</span>(<span style="color: #0000ff;">index</span>(索引名)) <span style="color: #0000ff;">where</span> num <span style="color: #808080;">= </span><span style="color: #008000;">@num</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">应尽量<span style="color: #ff0000;">避免在 where 子句中对字段进行表达式操作</span>，这将导致引擎放弃使用索引而进行全表扫描。如：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num<span style="color: #808080;">/</span><span style="font-weight: bold; color: #800000;">2 </span><span style="color: #808080;">= </span><span style="font-weight: bold; color: #800000;">100</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">应改为:</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> num <span style="color: #808080;">= </span><span style="font-weight: bold; color: #800000;">100</span><span style="color: #808080;">*</span><span style="font-weight: bold; color: #800000;">2</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">9.应尽量<span style="color: #ff0000;">避免在where子句中对字段进行函数操作</span>，这将导致引擎放弃使用索引而进行全表扫描。如：</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> <span style="color: #ff00ff;">substring</span>(name,<span style="font-weight: bold; color: #800000;">1</span>,<span style="font-weight: bold; color: #800000;">3</span>) <span style="color: #808080;">= </span><span style="color: #000000;">&#8217;abc&#8217;       -&#8211;name以abc开头的id </span><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> <span style="color: #ff00ff;">datediff</span>(<span style="color: #ff00ff;">day</span>,createdate,&#8217;<span style="font-weight: bold; color: #800000;">2005</span><span style="color: #808080;">-</span><span style="font-weight: bold; color: #800000;">11</span><span style="color: #808080;">-</span><span style="font-weight: bold; color: #800000;">30</span>&#8242;) <span style="color: #808080;">= </span><span style="font-weight: bold; color: #800000;">0    -</span>&#8211;&#8216;<span style="font-weight: bold; color: #800000;">2005</span><span style="color: #808080;">-</span><span style="font-weight: bold; color: #800000;">11</span><span style="color: #808080;">-</span><span style="font-weight: bold; color: #800000;">30</span>&#8217;    --生成的id</pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">应改为:</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> name <span style="color: #808080;">like</span> <span style="color: #ff0000;">'</span><span style="color: #ff0000;">abc%</span><span style="color: #ff0000;">'</span> <span style="color: #0000ff;">select</span> id <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> createdate <span style="color: #808080;">&gt;=</span> <span style="color: #ff0000;">'</span><span style="color: #ff0000;">2005-11-30</span><span style="color: #ff0000;">'</span> <span style="color: #808080;">and</span> createdate <span style="color: #808080;">&lt;</span> <span style="color: #ff0000;">'</span><span style="color: #ff0000;">2005-12-1</span><span style="color: #ff0000;">'</span></pre><p style="margin: 10px 0px; padding: 0px; text-indent: 28px; background-color: transparent;"></p><p style="margin: 10px 0px; padding: 0px; text-indent: 28px; background-color: transparent;">10.不要在 where 子句中的&#8220;=&#8221;左边进行函数、算术运算或其他表达式运算，否则系统将可能无法正确使用索引。</p><p style="margin: 10px 0px; padding: 0px; text-indent: 28px; background-color: transparent;">11.在使用索引字段作为条件时，如果该索引是复合索引，那么必须使用到该索引中的第一个字段作为条件时才能保证系统使用该索引，否则该索引将不会被使用，并且应尽可能的让字段顺序与索引顺序相一致。</p><p style="margin: 10px 0px; padding: 0px; text-indent: 28px; background-color: transparent;">12.不要写一些没有意义的查询，如需要生成一个空表结构：</p></div><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">select</span> col1,col2 <span style="color: #0000ff;">into</span> #t <span style="color: #0000ff;">from</span> t <span style="color: #0000ff;">where</span> <span style="font-weight: bold; color: #800000;">1</span><span style="color: #808080;">=</span><span style="font-weight: bold; color: #800000;">0</span></pre></div><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">这类代码不会返回任何结果集，但是会消耗系统资源的，应改成这样：</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">create table #t(&#8230;)</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">13.Update 语句，如果只更改1、2个字段，<span style="color: #ff0000;">不要Update全部字段</span>，否则频繁调用会引起明显的性能消耗，同时带来大量日志。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">14.对于多张大数据量（这里几百条就算大了）的表JOIN，要先分页再JOIN，否则逻辑读会很高，性能很差。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">15.select count(*) from table；这样不带任何条件的count会引起全表扫描，并且没有任何业务意义，是一定要杜绝的。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">16.索引并不是越多越好，索引固然可以提高相应的 select 的效率，但同时也降低了 insert 及 update 的效率，因为 insert 或 update 时有可能会重建索引，所以怎样建索引需要慎重考虑，视具体情况而定。一个表的索引数最好不要超过6个，若太多则应考虑一些不常使用到的列上建的索引是否有 必要。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">17.应尽可能的避免更新 clustered 索引数据列，因为 clustered 索引数据列的顺序就是表记录的物理存储顺序，一旦该列值改变将导致整个表记录的顺序的调整，会耗费相当大的资源。若应用系统需要频繁更新 clustered 索引数据列，那么需要考虑是否应将该索引建为 clustered 索引。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">18.尽量使用数字型字段，若只含数值信息的字段尽量不要设计为字符型，这会降低查询和连接的性能，并会增加存储开销。这是因为引擎在处理查询和连 接时会逐个比较字符串中每一个字符，而对于数字型而言只需要比较一次就够了。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">19.<span style="color: #ff0000;">尽可能的使用 varchar/nvarchar 代替 char/nchar</span>&nbsp;，因为首先变长字段存储空间小，可以节省存储空间，其次对于查询来说，在一个相对较小的字段内搜索效率显然要高些。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">20.任何地方都不要使用 select * from t ，用具体的字段列表代替&#8220;*&#8221;，<span style="color: #ff0000;">不要返回用不到的任何字段</span>。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">21.尽量使用表变量来代替临时表。如果表变量包含大量数据，请注意索引非常有限（只有主键索引）。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">22. 避免频繁创建和删除临时表，以减少系统表资源的消耗。临时表并不是不可使用，适当地使用它们可以使某些例程更有效，例如，当需要重复引用大型表或常用表中的某个数据集时。但是，对于一次性事件， 最好使用导出表。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">23.在新建临时表时，如果一次性插入数据量很大，那么可以使用 select into 代替 create table，避免造成大量 log ，以提高速度；如果数据量不大，为了缓和系统表的资源，应先create table，然后insert。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">24.如果使用到了临时表，在存储过程的最后务必将所有的临时表显式删除，先 truncate table ，然后 drop table ，这样可以避免系统表的较长时间锁定。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">25.<span style="color: #ff0000;">尽量避免使用游标，因为游标的效率较差</span>，如果游标操作的数据超过1万行，那么就应该考虑改写。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">26.使用基于游标的方法或临时表方法之前，应先寻找基于集的解决方案来解决问题，基于集的方法通常更有效。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">27.与临时表一样，游标并不是不可使用。对小型数据集使用 FAST_FORWARD 游标通常要优于其他逐行处理方法，尤其是在必须引用几个表才能获得所需的数据时。在结果集中包括&#8220;合计&#8221;的例程通常要比使用游标执行的速度快。如果开发时 间允许，基于游标的方法和基于集的方法都可以尝试一下，看哪一种方法的效果更好。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">28.在所有的存储过程和触发器的开始处设置 SET NOCOUNT ON ，在结束时设置 SET NOCOUNT OFF 。无需在执行存储过程和触发器的每个语句后向客户端发送 DONE_IN_PROC 消息。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">29.<span style="color: #ff0000;">尽量避免大事务操作，提高系统并发能力。</span></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">30.尽量避免向客户端返回大数据量，若数据量过大，应该考虑相应需求是否合理。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><strong>实际案例分析</strong>：拆分大的&nbsp;DELETE&nbsp;或INSERT&nbsp;语句，批量提交SQL语句</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">如果你需要在一个在线的网站上去执行一个大的&nbsp;DELETE&nbsp;或&nbsp;INSERT&nbsp;查询，你需要非常小心，要避免你的操作让你的整个网站停止相应。因为这两个操作是会锁表的，表一锁住了，别的操作都进不来了。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">Apache&nbsp;会有很多的子进程或线程。所以，其工作起来相当有效率，而我们的服务器也不希望有太多的子进程，线程和数据库链接，这是极大的占服务器资源的事情，尤其是内存。</p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><span style="color: #ff0000;">如果你把你的表锁上一段时间，比如30秒钟，那么对于一个有很高访问量的站点来说，这30秒所积累的访问进程/线程，数据库链接，打开的文件数，可能不仅仅会让你的WEB服务崩溃，还可能会让你的整台服务器马上挂了。</span></p><p style="margin: 10px 0px; padding: 0px; color: #333333; text-indent: 28px; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;">所以，如果你有一个大的处理，你一定把其拆分，使用&nbsp;LIMIT&nbsp;oracle(rownum),sqlserver(top)条件是一个好的方法。下面是一个mysql示例：<br style="clear: both; width: 0px; height: 0px;" /><br style="clear: both; width: 0px; height: 0px;" />&nbsp;</p><div style="color: #333333; font-family: 宋体; line-height: 28px; background-color: #f8f8f8;"><div>&nbsp;</div><pre style="margin-top: 0px; margin-bottom: 1em; padding: 0px; font-family: 'Courier New', monospace; font-size: 12px; width: 591.016px; overflow: auto; background: #e6e6e6;"><span style="color: #0000ff;">while</span>(1<span style="color: #000000;">){   </span><span style="color: #008000;">//</span><span style="color: #008000;">每次只做1000条</span>   <span style="color: #008080;">mysql_query</span>(&#8220;delete from logs where log_date &lt;= &#8217;2012-11-01&#8217; limit 1000<span style="color: #000000;">&#8221;);   </span><span style="color: #0000ff;">if</span>(<span style="color: #008080;">mysql_affected_rows</span>() == 0<span style="color: #000000;">){<br style="clear: both; width: 0px; height: 0px;" />  </span><span style="color: #008000;">//</span><span style="color: #008000;">删除完成，退出！</span>  <span style="color: #0000ff;">break</span><span style="color: #000000;">； }  </span><span style="color: #008000;">//</span><span style="color: #008000;">每次暂停一段时间，释放表让其他进程/线程访问。</span> <span style="color: #008080;">usleep</span>(50000<span style="color: #000000;">)  }</span></pre></div><img src ="http://www.blogjava.net/luyongfa/aggbug/429429.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2016-02-25 14:24 <a href="http://www.blogjava.net/luyongfa/articles/429429.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>获取八位UUID标识码</title><link>http://www.blogjava.net/luyongfa/archive/2016/01/19/429112.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Tue, 19 Jan 2016 07:17:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2016/01/19/429112.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/429112.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2016/01/19/429112.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/429112.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/429112.html</trackback:ping><description><![CDATA[<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->&nbsp;<span style="color: #0000FF; ">public</span>&nbsp;<span style="color: #0000FF; ">static</span>&nbsp;String[]&nbsp;chars&nbsp;=&nbsp;<span style="color: #0000FF; ">new</span>&nbsp;String[]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"a",&nbsp;"b",&nbsp;"c",&nbsp;"d",&nbsp;"e",&nbsp;"f",&nbsp;"g",&nbsp;"h",&nbsp;"i",&nbsp;"j",&nbsp;"k",&nbsp;"l",&nbsp;"m",&nbsp;"n",&nbsp;"o",&nbsp;"p",&nbsp;"q",&nbsp;"r",&nbsp;"s",&nbsp;"t",&nbsp;"u",&nbsp;"v",&nbsp;"w",&nbsp;"x",&nbsp;"y",&nbsp;"z",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"0",&nbsp;"1",&nbsp;"2",&nbsp;"3",&nbsp;"4",&nbsp;"5",&nbsp;"6",&nbsp;"7",&nbsp;"8",&nbsp;"9",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"A",&nbsp;"B",&nbsp;"C",&nbsp;"D",&nbsp;"E",&nbsp;"F",&nbsp;"G",&nbsp;"H",&nbsp;"I",&nbsp;"J",&nbsp;"K",&nbsp;"L",&nbsp;"M",&nbsp;"N",&nbsp;"O",&nbsp;"P",&nbsp;"Q",&nbsp;"R",&nbsp;"S",&nbsp;"T",&nbsp;"U",&nbsp;"V",&nbsp;"W",&nbsp;"X",&nbsp;"Y",&nbsp;"Z"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br /><br />&nbsp;&nbsp;<span style="color: #0000FF; ">public</span>&nbsp;<span style="color: #0000FF; ">static</span>&nbsp;String&nbsp;getShortUuid()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;StringBuffer&nbsp;stringBuffer&nbsp;=&nbsp;<span style="color: #0000FF; ">new</span>&nbsp;StringBuffer();<br />&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;uuid&nbsp;=&nbsp;UUID.randomUUID().toString().replace("-",&nbsp;"");<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>&nbsp;(<span style="color: #0000FF; ">int</span>&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;8;&nbsp;i++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;str&nbsp;=&nbsp;uuid.substring(i&nbsp;*&nbsp;4,&nbsp;i&nbsp;*&nbsp;4&nbsp;+&nbsp;4);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;strInteger&nbsp;=&nbsp;Integer.parseInt(str,&nbsp;16);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stringBuffer.append(chars[strInteger&nbsp;%&nbsp;0x3E]);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;stringBuffer.toString();<br />&nbsp;&nbsp;}</div><img src ="http://www.blogjava.net/luyongfa/aggbug/429112.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2016-01-19 15:17 <a href="http://www.blogjava.net/luyongfa/archive/2016/01/19/429112.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java开发必会的Linux命令</title><link>http://www.blogjava.net/luyongfa/archive/2015/12/25/428823.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Fri, 25 Dec 2015 02:13:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2015/12/25/428823.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/428823.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2015/12/25/428823.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/428823.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/428823.html</trackback:ping><description><![CDATA[<p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;">本文并不会对所有命令进行详细讲解，只给出常见用法和解释。具体用法可以使用<code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">--help</code>查看帮助或者直接通过google搜索学习。</p><h2>1.查找文件</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">find / -name filename.txt</code>&nbsp;根据名称查找/目录下的filename.txt文件。</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">find . -name "*.xml"</code>&nbsp;递归查找所有的xml文件</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">find . -name "*.xml" |xargs grep "hello world"</code>&nbsp;递归查找所有文件内容中包含hello world的xml文件</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">grep -H 'spring' *.xml</code>&nbsp;查找所以有的包含spring的xml文件</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">find ./ -size 0 | xargs rm -f &amp;</code>&nbsp;删除文件大小为零的文件</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">ls -l | grep '.jar'</code>&nbsp;查找当前目录中的所有jar文件</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">grep 'test' d*</code>&nbsp;显示所有以d开头的文件中包含test的行。</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">grep 'test' aa bb cc</code>&nbsp;显示在aa，bb，cc文件中匹配test的行。</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">grep '[a-z]\{5\}' aa</code>&nbsp;显示所有包含每个字符串至少有5个连续小写字符的字符串的行。</p><h2>2.查看一个程序是否运行</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">ps &#8211;ef|grep tomcat</code>&nbsp;查看所有有关tomcat的进程</p><h2>3.终止线程</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">kill -9 19979</code>&nbsp;终止线程号位19979的进程</p><h2>4.查看文件，包含隐藏文件</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">ls -al</code></p><h2>5.当前工作目录</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">pwd</code></p><h2>6.复制文件</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">cp source dest</code>&nbsp;复制文件</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">cp -r sourceFolder targetFolder</code>&nbsp;递归复制整个文件夹</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">scp sourecFile romoteUserName@remoteIp:remoteAddr</code>&nbsp;远程拷贝</p><h2>7.创建目录</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">mkdir newfolder</code></p><h2>8.删除目录</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">rmdir deleteEmptyFolder</code>&nbsp;删除空目录&nbsp;<code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">rm -rf deleteFile</code>&nbsp;递归删除目录中所有内容</p><h2>9.移动文件</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">mv /temp/movefile /targetFolder</code></p><h2>10.重命令</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">mv oldNameFile newNameFile</code></p><h2>11.切换用户</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">su -username</code></p><h2>12.修改文件权限</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">chmod 777 file.java</code>&nbsp;//file.java的权限-rwxrwxrwx，r表示读、w表示写、x表示可执行</p><h2>13.压缩文件</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">tar -czf test.tar.gz /test1 /test2</code></p><h2>14.列出压缩文件列表</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">tar -tzf test.tar.gz</code></p><h2>15.解压文件</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">tar -xvzf test.tar.gz</code></p><h2>16.查看文件头10行</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">head -n 10 example.txt</code></p><h2>17.查看文件尾10行</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">tail -n 10 example.txt</code></p><h2>18.查看日志类型文件</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">tail -f exmaple.log</code>&nbsp;//这个命令会自动显示新增内容，屏幕只显示10行内容的（可设置）。</p><h2>19.使用超级管理员身份执行命令</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">sudo rm a.txt</code>&nbsp;使用管理员身份删除文件</p><h2>20.查看端口占用情况</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">netstat -tln | grep 8080</code>&nbsp;查看端口8080的使用情况</p><h2>21.查看端口属于哪个程序</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">lsof -i :8080</code></p><h2>22.查看进程</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">ps aux|grep java</code>&nbsp;查看java进程</p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">ps aux</code>&nbsp;查看所有进程</p><h2>23.以树状图列出目录的内容</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">tree a</code></p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;">ps:<a href="http://www.hollischuang.com/archives/546" style="box-sizing: border-box; color: #2cdb87; transition: all 0.25s; background: 0px 0px;">Mac下使用tree命令</a></p><h2>24. 文件下载</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">wget http://file.tgz</code>&nbsp;<a href="http://www.hollischuang.com/archives/548" style="box-sizing: border-box; color: #2cdb87; transition: all 0.25s; background: 0px 0px;">mac下安装wget命令</a></p><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">curl http://file.tgz</code></p><h2>25. 网络检测</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">ping www.just-ping.com</code></p><h2>26.远程登录</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">ssh userName@ip</code></p><h2>27.打印信息</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; padding: 2px 4px; color: #c7254e; border-radius: 4px; background-color: #f9f2f4;">echo $JAVA_HOME</code>&nbsp;打印java home环境变量的值</p><h2>28.java 常用命令</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;">java javac&nbsp;<a href="http://www.hollischuang.com/archives/105" style="box-sizing: border-box; color: #2cdb87; transition: all 0.25s; background: 0px 0px;">jps</a>&nbsp;,<a href="http://www.hollischuang.com/archives/481" style="box-sizing: border-box; color: #2cdb87; transition: all 0.25s; background: 0px 0px;">jstat</a>&nbsp;,<a href="http://www.hollischuang.com/archives/303" style="box-sizing: border-box; color: #2cdb87; transition: all 0.25s; background: 0px 0px;">jmap</a>,&nbsp;<a href="http://www.hollischuang.com/archives/110" style="box-sizing: border-box; color: #2cdb87; transition: all 0.25s; background: 0px 0px;">jstack</a></p><h2>29.其他命令</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;">svn git maven</p><h2>28.linux命令学习网站:</h2><p style="box-sizing: border-box; margin: 0px 0px 18px; word-wrap: break-word; color: #555555; font-family: 'Microsoft Yahei'; font-size: 15px; line-height: 25px; background-color: #ffffff;"><a href="http://explainshell.com/" style="box-sizing: border-box; color: #2cdb87; transition: all 0.25s; background: 0px 0px;">http://explainshell.com/</a></p><img src ="http://www.blogjava.net/luyongfa/aggbug/428823.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2015-12-25 10:13 <a href="http://www.blogjava.net/luyongfa/archive/2015/12/25/428823.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>常用 Git 命令清单</title><link>http://www.blogjava.net/luyongfa/archive/2015/12/21/428759.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Mon, 21 Dec 2015 05:37:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2015/12/21/428759.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/428759.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2015/12/21/428759.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/428759.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/428759.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 常用 Git 命令清单我每天使用 Git ，但是很多命令记不住。一般来说，日常使用只要记住下图6个命令，就可以了。但是熟练使用，恐怕要记住60～100个命令。下面是我整理的常用 Git 命令清单。几个专用名词的译名如下。Workspace：工作区Index / Stage：暂存区Repository：仓库区（或本地仓库）Remote：远程仓库一、新建代码库 # 在当前目录新建一个Git代码库   ...&nbsp;&nbsp;<a href='http://www.blogjava.net/luyongfa/archive/2015/12/21/428759.html'>阅读全文</a><img src ="http://www.blogjava.net/luyongfa/aggbug/428759.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2015-12-21 13:37 <a href="http://www.blogjava.net/luyongfa/archive/2015/12/21/428759.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式)介绍</title><link>http://www.blogjava.net/luyongfa/archive/2015/04/03/424099.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Fri, 03 Apr 2015 05:28:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2015/04/03/424099.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/424099.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2015/04/03/424099.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/424099.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/424099.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: jedis是一个著名的key-value存储系统，而作为其官方推荐的java版客户端jedis也非常强大和稳定，支持事务、管道及有jedis自身实现的分布式。在这里对jedis关于事务、管道和分布式的调用方式做一个简单的介绍和对比：一、普通同步方式最简单和基础的调用方式，?1234567891011@Testpublic&nbsp;void&nbsp;test1Normal()&nbsp;{&nb...&nbsp;&nbsp;<a href='http://www.blogjava.net/luyongfa/archive/2015/04/03/424099.html'>阅读全文</a><img src ="http://www.blogjava.net/luyongfa/aggbug/424099.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2015-04-03 13:28 <a href="http://www.blogjava.net/luyongfa/archive/2015/04/03/424099.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>bitbucket入门手册，手把手操作指南</title><link>http://www.blogjava.net/luyongfa/archive/2015/03/11/423365.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Wed, 11 Mar 2015 02:40:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2015/03/11/423365.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/423365.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2015/03/11/423365.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/423365.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/423365.html</trackback:ping><description><![CDATA[<h1>Bitbucket<span style="font-family: 宋体;">使用说明：</span></h1><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="background: #ffff00;">使用者请直接看第一步，第二步和<span style="font-family: 'Times New Roman';">egit</span><span style="font-family: 宋体;">使用说明，</span></span></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">需要自己创建仓库的可以看三四步</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><h1><a name="t2" style="color: rgb(202, 0, 0);"></a>第一步：新用户注册<a target="_blank" href="http://blog.csdn.net/hk2291976/article/details/www.bitbucket.org" style="color: #ca0000; text-decoration: none;">www.bitbucket.org</a></h1><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><img src="http://img.my.csdn.net/uploads/201412/31/1419994975_1237.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">然后按步骤创建一个教程代码库</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419994960_6960.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">可以选择下载SourceTree&nbsp;<span style="font-family: 宋体;">和</span><span style="font-family: 'Times New Roman';">git&nbsp;&nbsp;&nbsp;SourceTree</span><span style="font-family: 宋体;">是一个客户端，图形界面，挺方便的</span></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419994960_1386.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">主界面有个教程，挺详细的，可以看看</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419994961_1606.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><h1><a name="t3" style="color: rgb(202, 0, 0);"></a>第二步：设置中文</h1><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">点右上角的小人图标，然后点击&#8220;Manage&nbsp;account&#8221;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419994961_7479.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">在<span style="font-family: 'Times New Roman';">Account&nbsp;settings&nbsp;</span><span style="font-family: 宋体;">里最下面有个选项，</span><span style="font-family: 'Times New Roman';">Language</span><span style="font-family: 宋体;">，改成</span><span style="font-family: 'Times New Roman';">Chinese</span></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><img src="http://img.my.csdn.net/uploads/201412/31/1419995032_7540.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><h1><a name="t4" style="color: rgb(202, 0, 0);"></a><br /></h1><h1><a name="t5" style="color: rgb(202, 0, 0);"></a>第三步：创建仓库</h1><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995033_4775.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419994959_1359.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">创建完可以用SourceTree<span style="font-family: 宋体;">复制代码进去，点击用</span><span style="font-family: 'Times New Roman';">SourceTree</span><span style="font-family: 宋体;">克隆</span></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995033_3629.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">会弹出这个窗口，可以更改目标路径（必须是空文件夹，不存在的最好）</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995034_8950.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">里面现在是空的，点击在文件管理器中打开</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995053_9393.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">把代码复制到这个文件夹</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><img src="http://img.my.csdn.net/uploads/201412/31/1419995053_6379.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">然后查看SourceTree<span style="font-family: 宋体;">，里面就有未保存的文件（如果没有，点击下日志</span><span style="font-family: 'Times New Roman';">/</span><span style="font-family: 宋体;">历史）点击&#8220;未暂存的文件&#8221;&nbsp;</span></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: 宋体;"><img src="http://img.my.csdn.net/uploads/201412/31/1419995053_8934.png" alt="" style="border: none; max-width: 100%;" /><br /></span></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">就会变成&#8220;已暂存的文件&#8221;&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995054_6614.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">然后点击工具栏的&#8221;提交&#8221;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995054_9413.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">输入需要说明的文字，点击提交</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1420008393_7077.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">这时候你可以看到分支那里有了东西，不过这个时候还只是在你的本地</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995097_9194.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">点击推送，就会放到服务器上</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995098_8016.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995098_7953.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">点击显示完整输出，可以看进度，如果变绿，出现执行成功，就行了，文件多会稍微慢点</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995099_5997.png" alt="" style="border: none; max-width: 100%;" /><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">然后去网站，刷新一下页面，就会出来信息</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995099_9836.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><h3><a name="t6" style="color: rgb(202, 0, 0);"></a>&nbsp;</h3><h3><a name="t7" style="color: rgb(202, 0, 0);"></a>&nbsp;</h3><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><h1><a name="t8" style="color: rgb(202, 0, 0);"></a>第四步：管理仓库</h1><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">源码部分可以下载和查看源码</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995121_7013.png" alt="" style="border: none; max-width: 100%;" /><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><img src="http://img.my.csdn.net/uploads/201412/31/1419995121_2217.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">提交部分可以查看提交记录</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995121_6276.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><img src="http://img.my.csdn.net/uploads/201412/31/1419995122_2935.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">点击提交下面的蓝字，可以查看这个版本修部分，每个变化文件都会显示出来，红色表示删除代码，绿表示添加代码，十分方便查看这个版本更新了什么，</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995122_1464.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">旁边的通知图标可以留言评论</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<img src="http://img.my.csdn.net/uploads/201412/31/1419995128_7536.png" alt="" style="border: none; max-width: 100%;" /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p><h3><a name="t9" style="color: rgb(202, 0, 0);"></a>&nbsp;</h3><h3><a name="t10" style="color: rgb(202, 0, 0);"></a><br /></h3><h1><a name="t11" style="color: rgb(202, 0, 0);"></a>第五步：代码更新</h1><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><br /></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">代码更新的一般步骤：<span style="color: #3366ff;">克隆代码&#8212;&#8212;修改&#8212;&#8212;提交&#8212;&#8212;推送</span></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;">Eclipse<span style="font-family: 宋体;">可以用</span><span style="font-family: 'Times New Roman';">egit</span><span style="font-family: 宋体;">方便完成，</span><span style="font-family: 'Times New Roman';">Qt</span><span style="font-family: 宋体;">有</span><span style="font-family: 'Times New Roman';">git</span><span style="font-family: 宋体;">工具，</span><span style="font-family: 'Times New Roman';">Vs</span><span style="font-family: 宋体;">有</span><span style="font-family: 'Times New Roman';">git</span><span style="font-family: 宋体;">插件，其他情况可以用</span><span style="font-family: 'Times New Roman';">sourceTree</span><span style="font-family: 宋体;">完成</span></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: 宋体;">具体的，可以查询其他资料，因为我目前是用java，我会再写一个egit的使用方法</span></p><img src ="http://www.blogjava.net/luyongfa/aggbug/423365.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2015-03-11 10:40 <a href="http://www.blogjava.net/luyongfa/archive/2015/03/11/423365.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL关于分组合并字段解决方案</title><link>http://www.blogjava.net/luyongfa/articles/421990.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Wed, 31 Dec 2014 07:49:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/articles/421990.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/421990.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/articles/421990.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/421990.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/421990.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;">之前遇到分组后合并某字段得问题，我都会自己去写个函数去实现。直至今天我才知道，原来各个数据库都提供了相关的函数，只是我不知道罢了。</span><br />
<span style="font-size: 10pt;">mysql提供的函数功能最为强大，oracle和</span><span style="color: #333333; font-family: arial; font-size: 10pt; line-height: 20.0200004577637px; background-color: #ffffff;">postgresql提供的函数只能实现单个字段合并</span><br />
<br />
1.mysql:<span style="color: #0000ff;"><strong>group_concat</strong></span>函数,demo如下：<br />
<div>表数据：<br />
<div><img src="http://www.blogjava.net/images/blogjava_net/luyongfa/QQ图片20141231150531.png" border="0" alt="" /><br />
SQL：<span style="font-size: 13px; color: #0000ff;">SELECT</span><span style="font-size: 13px; background-color: #eeeeee;">&nbsp;group_concat(name,</span><span style="font-size: 13px; color: #ff0000;">'</span><span style="font-size: 13px; color: #ff0000;">,</span><span style="font-size: 13px; color: #ff0000;">'</span><span style="font-size: 13px; background-color: #eeeeee;">,remark&nbsp;</span><span style="font-size: 13px; color: #0000ff;">order</span><span style="font-size: 13px; background-color: #eeeeee;">&nbsp;</span><span style="font-size: 13px; color: #0000ff;">by</span><span style="font-size: 13px; background-color: #eeeeee;">&nbsp;id&nbsp;</span><span style="font-size: 13px; color: #0000ff;">desc</span><span style="font-size: 13px; background-color: #eeeeee;">&nbsp;separator&nbsp;</span><span style="font-size: 13px; color: #ff0000;">'</span><span style="font-size: 13px; color: #ff0000;">;</span><span style="font-size: 13px; color: #ff0000;">'</span><span style="font-size: 13px; background-color: #eeeeee;">)&nbsp;</span><span style="font-size: 13px; color: #0000ff;">FROM</span><span style="font-size: 13px; background-color: #eeeeee;">&nbsp;test&nbsp;</span><span style="font-size: 13px; color: #0000ff;">group</span><span style="font-size: 13px; background-color: #eeeeee;">&nbsp;</span><span style="font-size: 13px; color: #0000ff;">by</span><span style="font-size: 13px; background-color: #eeeeee;">&nbsp;age;</span><br />
运行结果：<br />
<img src="http://www.blogjava.net/images/blogjava_net/luyongfa/QQ图片20141231150721.png" border="0" alt="" /><br />
<br />
2.oracle:<span style="color: #0000ff;"><strong>wmsys.wm_concat</strong></span><span>函数,功能比较简单,只能实现单字段间的合并,demo如下：<br />
表数据：<br />
<img src="http://www.blogjava.net/images/blogjava_net/luyongfa/QQ图片20141231151932.png" border="0" alt="" /><br />
<br />
</span>SQL:<br />
<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000FF; ">SELECT</span>&nbsp;<span style="color: #0000FF; ">DISTINCT</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;wmsys.wm_concat&nbsp;(NAME)&nbsp;<span style="color: #0000FF; ">OVER</span>&nbsp;(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PARTITION&nbsp;<span style="color: #0000FF; ">BY</span>&nbsp;AGE<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">ORDER</span>&nbsp;<span style="color: #0000FF; ">BY</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<span style="color: #0000FF; ">SELECT</span>&nbsp;<span style="color: #800000; font-weight: bold; ">1</span>&nbsp;<span style="color: #0000FF; ">FROM</span>&nbsp;dual)<br />
&nbsp;&nbsp;&nbsp;&nbsp;)<br />
<span style="color: #0000FF; ">FROM</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">SELECT</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #808080; ">*</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">FROM</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T_TEST<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">ORDER</span>&nbsp;<span style="color: #0000FF; ">BY</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ID&nbsp;<span style="color: #0000FF; ">DESC</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;T</div>
<span style="font-size: 13px; background-color: #eeeeee;">结果：</span><br />
<img src="http://www.blogjava.net/images/blogjava_net/luyongfa/QQ图片20141231153308.png" border="0" alt="" /><br />
<br />
<span style="font-size: 13px; background-color: #eeeeee;">3.</span><span style="color: #333333; font-family: arial; line-height: 20.0200004577637px; background-color: #ffffff;">Postgresql:</span><span style="color: #0000ff;"><strong>array_to_string</strong></span>以及<span style="color: #0000ff;"><strong>string_agg</strong></span>两个函数都能实现,推荐string_agg,demo如下:<br />
表数据:<br />
<img src="http://www.blogjava.net/images/blogjava_net/luyongfa/QQ%E5%9B%BE%E7%89%8720141231154353.png" border="0" alt="" style="font-size: 13px;" /><br />
<span style="background-color: #eeeeee;">SQL：<br />
</span>
<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
-->&nbsp; &nbsp; &nbsp;<span style="color: #0000FF; ">SELECT</span>&nbsp;id,array_to_string(ARRAY(<span style="color: #0000FF; ">SELECT</span>&nbsp;unnest(array_agg(name))&nbsp;<span style="color: #0000FF; ">order</span>&nbsp;<span style="color: #0000FF; ">by</span>&nbsp;<span style="color: #800000; font-weight: bold; ">1</span>),<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">;</span><span style="color: #FF0000; ">'</span>)&nbsp;<span style="color: #0000FF; ">FROM</span>&nbsp;t_kenyon&nbsp;<span style="color: #0000FF; ">GROUP</span>&nbsp;<span style="color: #0000FF; ">BY</span>&nbsp;id&nbsp;<span style="color: #0000FF; ">ORDER</span>&nbsp;<span style="color: #0000FF; ">BY</span>&nbsp;id;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">SELECT</span>&nbsp;id,string_agg(name,<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">;</span><span style="color: #FF0000; ">'</span>)&nbsp;<span style="color: #0000FF; ">FROM</span>&nbsp;t_kenyon&nbsp;<span style="color: #0000FF; ">GROUP</span>&nbsp;<span style="color: #0000FF; ">BY</span>&nbsp;id&nbsp;<span style="color: #0000FF; ">ORDER</span>&nbsp;<span style="color: #0000FF; ">BY</span>&nbsp;id;</div>
<span style="font-size: 13px; background-color: #eeeeee;">结果：</span><br />
<img src="http://www.blogjava.net/images/blogjava_net/luyongfa/QQ%E5%9B%BE%E7%89%8720141231154545.png" border="0" alt="" /><span style="background-color: #eeeeee;"><br />
</span>
</div>
</div><img src ="http://www.blogjava.net/luyongfa/aggbug/421990.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2014-12-31 15:49 <a href="http://www.blogjava.net/luyongfa/articles/421990.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>获取ApplicationContext</title><link>http://www.blogjava.net/luyongfa/archive/2014/12/26/421863.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Fri, 26 Dec 2014 09:06:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2014/12/26/421863.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/421863.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2014/12/26/421863.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/421863.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/421863.html</trackback:ping><description><![CDATA[<p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">一、简单的用ApplicationContext做测试的话,获得Spring中定义的Bean实例(对象).可以用:</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");<br />RegisterDAO registerDAO = (RegisterDAO)ac.getBean("RegisterDAO");</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">如果是两个以上:<br />ApplicationContext ac = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml","dao.xml"});<br /></p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">或者用通配符:<br />ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/*.xml");</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;"><br />二、ClassPathXmlApplicationContext[只能读放在web-info/classes目录下的配置文件]和FileSystemXmlApplicationContext的区别<br /></p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">classpath:前缀是不需要的,默认就是指项目的classpath路径下面;<br />如果要使用绝对路径,需要加上file:前缀表示这是绝对路径;</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">对于FileSystemXmlApplicationContext:<br />默认表示的是两种:</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">1.没有盘符的是项目工作路径,即项目的根目录;<br />2.有盘符表示的是文件绝对路径.</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">如果要使用classpath路径,需要前缀classpath:</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">public class HelloClient {</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">&nbsp; protected static final Log log = LogFactory.getLog(HelloClient.class);</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">&nbsp; public static void main(String[] args) {<br />&nbsp;&nbsp;&nbsp; // Resource resource = new ClassPathResource("appcontext.xml");<br />&nbsp;&nbsp;&nbsp; // BeanFactory factory = new XmlBeanFactory(resource);</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; // 用classpath路径<br />&nbsp;&nbsp;&nbsp; // ApplicationContext factory = new ClassPathXmlApplicationContext("classpath:appcontext.xml");<br />&nbsp;&nbsp;&nbsp; // ApplicationContext factory = new ClassPathXmlApplicationContext("appcontext.xml");</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; // ClassPathXmlApplicationContext使用了file前缀是可以使用绝对路径的<br />&nbsp;&nbsp;&nbsp; // ApplicationContext factory = new ClassPathXmlApplicationContext("file:F:/workspace/example/src/appcontext.xml");</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; // 用文件系统的路径,默认指项目的根路径<br />&nbsp;&nbsp;&nbsp; // ApplicationContext factory = new FileSystemXmlApplicationContext("src/appcontext.xml");<br />&nbsp; &nbsp; // ApplicationContext factory = new FileSystemXmlApplicationContext("webRoot/WEB-INF/appcontext.xml");<br /><br /></p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; // 使用了classpath:前缀,这样,FileSystemXmlApplicationContext也能够读取classpath下的相对路径<br />&nbsp;&nbsp;&nbsp; // ApplicationContext factory = new FileSystemXmlApplicationContext("classpath:appcontext.xml");<br />&nbsp;&nbsp;&nbsp; // ApplicationContext factory = new FileSystemXmlApplicationContext("file:F:/workspace/example/src/appcontext.xml");</p><p style="margin: 0px 0px 14px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; // 不加file前缀<br />&nbsp;&nbsp;&nbsp; ApplicationContext factory = new FileSystemXmlApplicationContext("F:/workspace/example/src/appcontext.xml");<br />&nbsp;&nbsp;&nbsp; IHelloWorld hw = (IHelloWorld)factory.getBean("helloworldbean");<br />&nbsp;&nbsp;&nbsp; log.info(hw.getContent("luoshifei"));<br />&nbsp; }<br />}</p><img src ="http://www.blogjava.net/luyongfa/aggbug/421863.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2014-12-26 17:06 <a href="http://www.blogjava.net/luyongfa/archive/2014/12/26/421863.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>solr4删除索引 </title><link>http://www.blogjava.net/luyongfa/articles/413630.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Tue, 13 May 2014 14:11:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/articles/413630.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/413630.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/articles/413630.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/413630.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/413630.html</trackback:ping><description><![CDATA[<div><p>通过web方式提交索引和删除索引</p><p><br /></p><p><div><span style="color: &33333; line-height: 26px; font-family: Arial;">Solr 删除指定索引：</span></div>http://localhost:8081/solr/solrtest/update/?stream.body=<delete><id>solr123456</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true</p><p>&#160;</p><p><span style="color: &33333; line-height: 26px; font-family: Arial;">Solr 删除全部索引：</span><a style="color: &36699; line-height: 26px; font-family: Arial;" href="http://localhost:8080/solr/update/?stream.body=%3Cdelete%3E%3Cquery%3E*:*%3C/query%3E%3C/delete%3E&stream.contentType=text/xml;charset=utf-8&commit=true">http://localhost:8080/solr/update/?stream.body=<delete><query>*:*</query></delete>&stream.contentType=text/xml;charset=utf-8&commit=true</a></p><p>&#160;</p></div>  <img src ="http://www.blogjava.net/luyongfa/aggbug/413630.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2014-05-13 22:11 <a href="http://www.blogjava.net/luyongfa/articles/413630.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SolrJ开发文档 </title><link>http://www.blogjava.net/luyongfa/articles/412776.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Tue, 22 Apr 2014 02:40:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/articles/412776.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/412776.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/articles/412776.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/412776.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/412776.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Solr 是一种可供企业使用的、基于 Lucene 的搜索服务器，它支持层面搜索、命中醒目显示和多种输出格式。在这篇文章中，将介绍 Solr 并展示如何轻松地将其表现优异的全文本搜索功能加入到 Web 应用程序中。  开发环境：  System：Windows  WebBrowser：IE6+、Firefox3+  JDK：1.6+  JavaEE Server：tomcat5.0.2.8、tom...&nbsp;&nbsp;<a href='http://www.blogjava.net/luyongfa/articles/412776.html'>阅读全文</a><img src ="http://www.blogjava.net/luyongfa/aggbug/412776.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2014-04-22 10:40 <a href="http://www.blogjava.net/luyongfa/articles/412776.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ajax跨域请求</title><link>http://www.blogjava.net/luyongfa/archive/2013/12/26/408047.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Thu, 26 Dec 2013 01:24:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/12/26/408047.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/408047.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/12/26/408047.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/408047.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/408047.html</trackback:ping><description><![CDATA[$.ajax({<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type : "get",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; async:false,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url : url,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataType : "jsonp",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; success : function(data){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var param = data.status;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ("1" == param) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.location.reload();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(data.message);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error:function(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert('操作失败');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br /><br /><br />服务端：<br />&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;String cb = request.getParameter("callback");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (cb != null) {//如果是跨域<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringBuffer sb = new StringBuffer(cb);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sb.append("(");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sb.append(result);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sb.append(")");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<img src ="http://www.blogjava.net/luyongfa/aggbug/408047.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-12-26 09:24 <a href="http://www.blogjava.net/luyongfa/archive/2013/12/26/408047.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux下Tomcat的启动、关闭、杀死进程 </title><link>http://www.blogjava.net/luyongfa/archive/2013/08/28/403399.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Wed, 28 Aug 2013 05:14:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/08/28/403399.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/403399.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/08/28/403399.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/403399.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/403399.html</trackback:ping><description><![CDATA[<div>打开终端<br />cd /java/tomcat<br />#执行<br />bin/startup.sh #启动tomcat<br />bin/shutdown.sh #停止tomcat<br />tail -f logs/catalina.out #看tomcat的控制台输出；</div><div>&nbsp;</div><div>#看是否已经有tomcat在运行了<br />ps -ef |grep tomcat </div><div>#如果有，用kill;<br />kill -9 pid #pid 为相应的进程号</div><div>&nbsp;</div><div>例如 ps -ef |grep tomcat 输出如下</div><div>sun 5144 1 0 10:21 pts/1 00:00:06 /java/jdk/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/java/tomcat/common/endorsed -classpath :/java/tomcat/bin/bootstrap.jar:/java/tomcat/bin/commons-logging-api.jar -Dcatalina.base=/java/tomcat -Dcatalina.home=/java/tomcat -Djava.io.tmpdir=/java/tomcat/temp org.apache.catalina.startup.Bootstrap start</div><div>&nbsp;</div><div>则 5144 就为进程号 pid = 5144<br />kill -9 5144 就可以彻底杀死tomcat </div><div>&nbsp;</div><div>#直接查看指定端口的进程pid</div><div>netstat -anp|grep 9217</div><div>#结果为 tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 :::9217&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :::*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26127/java</div><div>#则26127为9217这个端口的tomcat进程的pid,然后就可以kill这个进程</div><div>kill -9 26127</div><div>#然后再启动tomcat即可</div><img src ="http://www.blogjava.net/luyongfa/aggbug/403399.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-08-28 13:14 <a href="http://www.blogjava.net/luyongfa/archive/2013/08/28/403399.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在CentOS6.3上如何用yum安装nginx</title><link>http://www.blogjava.net/luyongfa/archive/2013/08/28/403393.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Wed, 28 Aug 2013 02:25:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/08/28/403393.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/403393.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/08/28/403393.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/403393.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/403393.html</trackback:ping><description><![CDATA[<p>默认的yum源比较老也不全，在update这的那的之后，还是没有nginx的身影, 别折腾了, 标准包是没有这玩意儿的。</p><pre class="prettyprint" style="background: rgb(240, 240, 240);"><code><span class="pln">
    wget http</span><span class="pun">:</span><span class="com">//www.atomicorp.com/installers/atomic  #下载atomic yum源</span><span class="pln">

    sh </span><span class="pun">./</span><span class="pln">atomic   </span><span class="com">#安装</span><span class="pln">

    yum check</span><span class="pun">-</span><span class="pln">update  </span><span class="com">#更新yum软件包</span></code><br /></pre><p>2、安装nginx：</p><pre class="prettyprint" style="background: rgb(240, 240, 240);"><code><span class="pln">
    yum install nginx      </span><span class="com">#安装nginx，根据提示，输入Y安装即可成功安装</span><span class="pln">

    </span><span class="com">#修改配置文件，这里省略，主要是将目录指定到 /home/ngmsw-files</span><span class="pln">

    service nginx start    </span><span class="com">#启动</span><span class="pln">

    chkconfig  nginx on    </span><span class="com">#设为开机启动</span></code></pre><img src ="http://www.blogjava.net/luyongfa/aggbug/403393.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-08-28 10:25 <a href="http://www.blogjava.net/luyongfa/archive/2013/08/28/403393.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Centos下启用mysql的远程访问账号 </title><link>http://www.blogjava.net/luyongfa/archive/2013/08/28/403389.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Wed, 28 Aug 2013 02:10:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/08/28/403389.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/403389.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/08/28/403389.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/403389.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/403389.html</trackback:ping><description><![CDATA[<p>在默认情况下mysql是不允许远程访问的.</p><p>现在需要添加一个可以具有原创访问的mysql账号(需要进入mysql命令行下):</p><p><strong>GRANT ALL PRIVILEGES ON *.* TO <a>remote@"%</a>" IDENTIFIED BY '远程登录的明文密码' WITH GRANT OPTION; </strong></p><p>执行如下语句生效: </p><p><strong>flush privileges;</strong></p><img src ="http://www.blogjava.net/luyongfa/aggbug/403389.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-08-28 10:10 <a href="http://www.blogjava.net/luyongfa/archive/2013/08/28/403389.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux下安装jdk1.6 </title><link>http://www.blogjava.net/luyongfa/archive/2013/08/27/403377.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Tue, 27 Aug 2013 09:34:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/08/27/403377.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/403377.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/08/27/403377.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/403377.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/403377.html</trackback:ping><description><![CDATA[<p>一、安装</p><p>创建安装目录，在/usr/java下建立安装路径，并将文件考到该路径下：&nbsp;<br /><br /> # mkdir /usr/java</p><p>&nbsp;</p><p>1、<span style="color: rgb(255, 102, 0);">jdk-6u11-linux-i586.bin </span> 这个是自解压的文件，在linux上安装如下：&nbsp;<br /><br /> # chmod 755 jdk-6u11-linux-i586.bin&nbsp;<br /><br /> # ./jdk-6u11-linux-i586.bin （注意，这个步骤一定要在jdk-6u11-linux-i586.bin所在目录下）<br /><br /> 在按提示输入yes后，jdk被解压。</p><p>&nbsp;出现一行字：Do you aggree to the above license terms? [yes or no]<br /><br /> &nbsp; 安装程序在问您是否愿意遵守刚才看过的许可协议。当然要同意了，输入"y" 或 "yes" 回车。<br /><br />2、若是用<span style="color: rgb(255, 102, 0);">jdk-6u11-linux-i586-rpm.bin</span> 这个也是一个自解压文件，不过解压后的文件是<span style="color: rgb(255, 102, 0);">jdk-6u11-linux-i586-rpm</span> 包，执行rpm命令装到linux上就可以了。安装如下：&nbsp;<br /><br /> #chmod 755 ./<span style="color: rgb(255, 102, 0);">jdk-6u11-linux-i586-rpm</span> &nbsp;<br /><br /> # ./<span style="color: rgb(255, 102, 0);">jdk-6u11-linux-i586-rpm</span> .bin&nbsp;<br /><br /> # rpm -ivh <span style="color: rgb(255, 102, 0);">jdk-6u11-linux-i586-rpm</span></p><p>&nbsp;</p><p>出现一行字：Do you aggree to the above license terms? [yes or no]<br /><br /> &nbsp; 安装程序在问您是否愿意遵守刚才看过的许可协议。当然要同意了，输入"y" 或 "yes" 回车。<br /><br /> 安装软件会将JDK自动安装到 /usr/java/目录下。&nbsp;<br /><br />二、配置<br />&nbsp;#vi /etc/profile<br /><br /> &nbsp; 在里面添加如下内容<br /><br /></p><p>export JAVA_HOME=/usr/java/jdk1.6.0_27</p><p>export JAVA_BIN=/usr/java/jdk1.6.0_27/bin</p><p>export PATH=$PATH:$JAVA_HOME/bin</p><p>export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar</p><p>export JAVA_HOME JAVA_BIN PATH CLASSPATH</p><p><span style="background-color: rgb(0, 255, 0);">让/etc/profile文件修改后立即生效 ,可以使用如下命令:<br /><br /> &nbsp;# .&nbsp; /etc/profile<br /><br />注意: . 和 /etc/profile 有空格.</span> <br /><br /> &nbsp;<br />重启测试<br /><br />&nbsp; java -version<br /><br /> &nbsp; 屏幕输出:<br /><br /> &nbsp; java version "jdk1.6.0_02"<br /> &nbsp; Java(TM) 2 Runtime Environment, Standard Edition (build jdk1.6.0_02)<br /> &nbsp; Java HotSpot(TM) Client VM (build jdk1.6.0_02, mixed mode)</p><img src ="http://www.blogjava.net/luyongfa/aggbug/403377.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-08-27 17:34 <a href="http://www.blogjava.net/luyongfa/archive/2013/08/27/403377.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux Tomcat安装 </title><link>http://www.blogjava.net/luyongfa/archive/2013/08/27/403376.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Tue, 27 Aug 2013 09:33:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/08/27/403376.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/403376.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/08/27/403376.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/403376.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/403376.html</trackback:ping><description><![CDATA[<p>&nbsp;</p><div style="padding: 4px 5px 4px 4px; border: 1px solid rgb(204, 204, 204); width: 98%; font-size: 13px; -ms-word-break: break-all; background-color: rgb(238, 238, 238);"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;为了学习java，需要一个服务器，因此决定用比较流行的tomcat。根据网上对安装tomcat的介绍，自己进行了安装，现在已经成功了，现在把安装的过程进行记录，也供大家学习参考。<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;一、从官方网站上下载tomcat软件包。<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;http:</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">tomcat.apache.org/</span><span style="color: rgb(0, 128, 0);"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;点击左侧的&nbsp;download的一个版本，我选择的是&nbsp;tomcat6.x,你可以根据自己的实际情况进行选择安装，点击超连接，选择&nbsp;Binary&nbsp;Distributions&nbsp;下的tar.gz&nbsp;(pgp,&nbsp;md5)&nbsp;压缩包，进行下载<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;二、下载到本地后，进行解压<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;#tar&nbsp;zxvf&nbsp;apach</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tomcat</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">6.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);">.tar.gz<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;#mv&nbsp;apach</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tomcat</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">6.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;三、进行tomcat环境的配置(前提需要安装jdk)<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;#vi&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">profile&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;export&nbsp;JAVA_HOME</span><span style="color: rgb(0, 0, 0);">=/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">jdk1.</span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">.0_04<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;export&nbsp;TOMCAT_HOME</span><span style="color: rgb(0, 0, 0);">=/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apach</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tomcat</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">6.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;保存退出&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;source&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">profile&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">让当前配置立即生效</span><span style="color: rgb(0, 128, 0);"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;四、启动tomcat服务器&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;$&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apach</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tomcat</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">6.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">startup.sh&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;我的电脑上会出现如下内容：&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;Using&nbsp;CATALINA_BASE:&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apache</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tomcat</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">6.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;Using&nbsp;CATALINA_HOME:&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apache</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tomcat</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">6.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;Using&nbsp;CATALINA_TMPDIR:&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apache</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tomcat</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">6.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">16</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">temp<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;Using&nbsp;JRE_HOME:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">jdk1.</span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">.0_04<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;五、在浏览器中输入http:</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">localhost:8080/就可以看到tomcat的log了</span><span style="color: rgb(0, 128, 0);"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;tomcat的安装到此结束。<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /></span></div><p>&nbsp;</p><img src ="http://www.blogjava.net/luyongfa/aggbug/403376.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-08-27 17:33 <a href="http://www.blogjava.net/luyongfa/archive/2013/08/27/403376.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>sql去重</title><link>http://www.blogjava.net/luyongfa/archive/2013/08/27/403369.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Tue, 27 Aug 2013 07:39:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/08/27/403369.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/403369.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/08/27/403369.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/403369.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/403369.html</trackback:ping><description><![CDATA[<p><br />create table temp_dp_id_ent_info as select min(id) as id from dianping_deal_business group by deal_id,business_id having count(1)&gt;1;<br />create table temp_dp_deal_id_ent_info as select deal_id from dianping_deal_business group by deal_id,business_id having count(1)&gt;1;</p><p><br />delete from dianping_deal_business<br />where deal_id in (select deal_id from temp_dp_id_ent_info)<br />and id not in (select id from temp_dp_id_ent_info);</p><p>drop table temp_dp_id_ent_info;<br />drop table temp_dp_deal_id_ent_info;<br /></p><img src ="http://www.blogjava.net/luyongfa/aggbug/403369.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-08-27 15:39 <a href="http://www.blogjava.net/luyongfa/archive/2013/08/27/403369.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POI读写EXcel</title><link>http://www.blogjava.net/luyongfa/archive/2013/08/22/403180.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Thu, 22 Aug 2013 06:02:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/08/22/403180.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/403180.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/08/22/403180.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/403180.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/403180.html</trackback:ping><description><![CDATA[<p>package com.wo116114.action;</p><p>import java.io.File;<br />import java.io.FileInputStream;<br />import java.io.FileOutputStream;<br />import java.io.IOException;<br />import java.io.InputStream;</p><p>import org.apache.poi.hssf.usermodel.HSSFWorkbook;<br />import org.apache.poi.ss.usermodel.Cell;<br />import org.apache.poi.ss.usermodel.Row;<br />import org.apache.poi.ss.usermodel.Sheet;<br />import org.apache.poi.ss.usermodel.Workbook;<br />import org.apache.poi.xssf.usermodel.XSSFWorkbook;</p><p>public class TestReadAndWrite {<br />&nbsp;public static void main(String[] args) throws IOException {<br />&nbsp;&nbsp;String path = "D:/dianping/gather/";<br />&nbsp;&nbsp;String fileName = "result";<br />&nbsp;&nbsp;String fileType = "xlsx";<br />&nbsp;&nbsp; writer(path, fileName, fileType);<br />&nbsp;&nbsp; <br />&nbsp;&nbsp;read(path, fileName, fileType);<br />&nbsp;}</p><p>&nbsp;private static void writer(String path, String fileName, String fileType)<br />&nbsp;&nbsp;&nbsp;throws IOException {<br />&nbsp;&nbsp;InputStream stream = new FileInputStream(path + fileName + "."<br />&nbsp;&nbsp;&nbsp;&nbsp;+ fileType);<br />&nbsp;&nbsp;// 创建工作文档对象<br />&nbsp;&nbsp;Workbook wb = null;<br />&nbsp;&nbsp;if (fileType.equals("xls")) {<br />&nbsp;&nbsp;&nbsp;wb = new HSSFWorkbook(stream);<br />&nbsp;&nbsp;} else if (fileType.equals("xlsx")) {<br />&nbsp;&nbsp;&nbsp;wb = new XSSFWorkbook(stream);<br />&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;System.out.println("您的文档格式不正确！");<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;// 创建sheet对象<br />&nbsp;&nbsp;Sheet sheet1 = (Sheet) wb.getSheetAt(0);<br />&nbsp;&nbsp;// 循环写入行数据<br />&nbsp;&nbsp; int num = sheet1.getLastRowNum() + 1;<br />&nbsp;&nbsp;for (int i = 0; i &lt; 5; i++) {<br />&nbsp;&nbsp;&nbsp;Row row = (Row) sheet1.createRow(num+i);<br />&nbsp;&nbsp;&nbsp;// 循环写入列数据<br />&nbsp;&nbsp;&nbsp;for (int j = 0; j &lt; 8; j++) {<br />&nbsp;&nbsp;&nbsp;&nbsp;Cell cell = row.createCell(j);<br />&nbsp;&nbsp;&nbsp;&nbsp;cell.setCellValue("测试" + j);<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;File file = new File(path + fileName + "." + fileType);<br />&nbsp;&nbsp;FileOutputStream fileOut = new FileOutputStream(file);<br />&nbsp;&nbsp;wb.write(fileOut);<br />&nbsp;&nbsp;fileOut.close();<br />&nbsp;&nbsp;stream.close();<br />&nbsp;}</p><p>&nbsp;public static void read(String path, String fileName, String fileType)<br />&nbsp;&nbsp;&nbsp;throws IOException {<br />&nbsp;&nbsp;InputStream stream = new FileInputStream(path + fileName + "."<br />&nbsp;&nbsp;&nbsp;&nbsp;+ fileType);<br />&nbsp;&nbsp;Workbook wb = null;<br />&nbsp;&nbsp;if (fileType.equals("xls")) {<br />&nbsp;&nbsp;&nbsp;wb = new HSSFWorkbook(stream);<br />&nbsp;&nbsp;} else if (fileType.equals("xlsx")) {<br />&nbsp;&nbsp;&nbsp;wb = new XSSFWorkbook(stream);<br />&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;System.out.println("您输入的excel格式不正确");<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;Sheet sheet1 = wb.getSheetAt(0);<br />&nbsp;&nbsp;for (Row row : sheet1) {<br />&nbsp;&nbsp;&nbsp;for (Cell cell : row) {<br />&nbsp;&nbsp;&nbsp;&nbsp;System.out.print(cell.getStringCellValue() + "&nbsp; ");<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;System.out.println();<br />&nbsp;&nbsp;}<br />&nbsp;}<br />}<br /></p><img src ="http://www.blogjava.net/luyongfa/aggbug/403180.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-08-22 14:02 <a href="http://www.blogjava.net/luyongfa/archive/2013/08/22/403180.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PostgreSQL数据库切割和组合字段函数</title><link>http://www.blogjava.net/luyongfa/archive/2013/05/15/399295.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Wed, 15 May 2013 02:24:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/05/15/399295.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/399295.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/05/15/399295.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/399295.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/399295.html</trackback:ping><description><![CDATA[一.组合函数 <br />1.concat <br /> a.介绍 <pre>concat(str "any" [, str "any" [, ...]])

Concatenate all but first arguments with separators.
The first parameter is used as a separator. 
NULL arguments are ignored.</pre>b.实际例子: <pre>postgres=# create table t_kenyon(id int,name varchar(10),remark text);
CREATE TABLE
postgres=# insert into t_kenyon values(1,'test','kenyon'),(2,'just','china'),(3,'iam','lovingU');
INSERT 0 3
postgres=# insert into t_kenyon values(4,'test',null);
INSERT 0 1
postgres=# insert into t_kenyon values(5,null,'adele');
INSERT 0 1
postgres=# select * from t_kenyon;
 id | name | remark  
----+------+---------
  1 | test | kenyon
  2 | just | china
  3 | iam  | lovingU
  4 | test | 
  5 |      | adele
(5 rows)

postgres=# select concat(id,name,remark) from t_kenyon;
   concat    
-------------
 1testkenyon
 2justchina
 3iamlovingU
 4test
 5adele
(5 rows)</pre>c.说明 concat函数纯粹是一个拼接函数，可以忽略null值拼接，拼接的值没有分隔符，如果需要分割符，则需要用下面的函数concat_ws。 <br /><br />2.concat_ws <br /> a.介绍 <pre>concat_ws(sep text, str "any" [, str "any" [,...] ])

Concatenate all but first arguments with separators.
The first parameter is used as a separator.
NULL arguments are ignored.</pre>b.实际应用 <pre>postgres=# select concat_ws(',',id,name,remark) from t_kenyon;
   concat_ws   
---------------
 1,test,kenyon
 2,just,china
 3,iam,lovingU
 4,test
 5,adele
(5 rows)

postgres=# select concat_ws('_',id,name,remark) from t_kenyon;
   concat_ws   
---------------
 1_test_kenyon
 2_just_china
 3_iam_lovingU
 4_test
 5_adele
(5 rows)

postgres=# select concat_ws('',id,name,remark) from t_kenyon;
  concat_ws  
-------------
 1testkenyon
 2justchina
 3iamlovingU
 4test
 5adele
(5 rows)

postgres=# select concat_ws('^_*',id,name,remark) from t_kenyon;
     concat_ws     
-------------------
 1^_*test^_*kenyon
 2^_*just^_*china
 3^_*iam^_*lovingU
 4^_*test
 5^_*adele
(5 rows)</pre>c.说明 concat_ws函数比concat函数多了分隔符的功能，其实就是concat的升级版，假如分隔符为'',则取出来的结果和concat是一样的。其功能与mysql中的group_concat函数比较类似，但也有不同，pg中concat_ws分隔符还支持多个字符作为分隔符的，日常用得更多的可能是||。&nbsp; <br /><br />二、切割函数 <br />1.split_part <br /> a.介绍 <pre>split_part(string text, delimiter text, field int)

Split string on delimiter and return the given field (counting from one)</pre>b.实际例子 <pre>postgres=# select split_part('abc~@~def~@~ghi','~@~', 2);
 split_part 
------------
 def
(1 row)

postgres=# select split_part('now|year|month','|',3);
 split_part 
------------
 month
(1 row)</pre>c.说明 该函数对按分隔符去取某个特定位置上的值非常有效果 <br /><br />2.regexp_split_to_table <br /> a.介绍 <pre>regexp_split_to_table(string text, pattern text [, flags text])

Split string using a POSIX regular expression as the delimiter.</pre>b.使用例子 <pre>postgres=# SELECT regexp_split_to_table('kenyon,love,,china,!',',');
 regexp_split_to_table 
-----------------------
 kenyon
 love
 
 china
 !
(5 rows)

--按分割符切割
postgres=# SELECT regexp_split_to_table('kenyon,china,loves',',');
 regexp_split_to_table 
-----------------------
 kenyon
 china
 loves
(3 rows)

--按字母切割
postgres=# SELECT regexp_split_to_table('kenyon,,china',E'\\s*');
 regexp_split_to_table 
-----------------------
 k
 e
 n
 y
 o
 n
 ,
 ,
 c
 h
 i
 n
 a
(13 rows)</pre>3.regexp_split_to_array <br /> a.介绍 <pre>regexp_split_to_array(string text, pattern text [, flags text ])

Split string using a POSIX regular expression as the delimiter.</pre>b.实际例子 <pre>postgres=# SELECT regexp_split_to_array('kenyon,love,,china,!',',');
  regexp_split_to_array   
--------------------------
 {kenyon,love,"",china,!}
(1 row)

postgres=# SELECT regexp_split_to_array('kenyon,love,,china!','s*');
             regexp_split_to_array             
-----------------------------------------------
 {k,e,n,y,o,n,",",l,o,v,e,",",",",c,h,i,n,a,!}
(1 row)</pre>c.说明 <br /> 上面用到的flag里的s*表示split all <img src ="http://www.blogjava.net/luyongfa/aggbug/399295.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-05-15 10:24 <a href="http://www.blogjava.net/luyongfa/archive/2013/05/15/399295.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>将私有的jar包导入到maven本地库</title><link>http://www.blogjava.net/luyongfa/archive/2013/04/26/398425.html</link><dc:creator>Mr.lu</dc:creator><author>Mr.lu</author><pubDate>Fri, 26 Apr 2013 03:15:00 GMT</pubDate><guid>http://www.blogjava.net/luyongfa/archive/2013/04/26/398425.html</guid><wfw:comment>http://www.blogjava.net/luyongfa/comments/398425.html</wfw:comment><comments>http://www.blogjava.net/luyongfa/archive/2013/04/26/398425.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/luyongfa/comments/commentRss/398425.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/luyongfa/services/trackbacks/398425.html</trackback:ping><description><![CDATA[<p>将私有的jar包或者maven(<a href="http://maven.apache.org">http://maven.apache.org</a><span style="color: rgb(0, 0, 255);"></span>)找不到匹配的jar包，导入到本地库中</p><p>&nbsp;</p><p>mvn install:install-file -Dfile=d:/Downloads/apache-activemq-5.5.0/lib/activemq-core-5.5.0.jar -DgroupId=org.apache.activemq -DartifactId=activemq-core -Dversion=5.5.0 -Dpackaging=jar</p><p>&nbsp;</p><p>&nbsp;</p><p><span style="font-family: mceinline;"><span style="font-family: mceinline;">解析：</span></span></p><p>mvn install:install-file &nbsp;-Dfile=外部包的路径 / &nbsp;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -DgroupId=外部包的groupId / &nbsp;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -DartifactId=外部包的artifactId / &nbsp;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -Dversion=外部包的版本号 / &nbsp;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Dpackaging=jar</p><img src ="http://www.blogjava.net/luyongfa/aggbug/398425.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/luyongfa/" target="_blank">Mr.lu</a> 2013-04-26 11:15 <a href="http://www.blogjava.net/luyongfa/archive/2013/04/26/398425.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>