<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 41, comments - 15, trackbacks - 0, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    oracle10g以上版本提供行轉列組合成字符串函數wm_concat,注意跟其他字段一起select的時候要用group by

    例如有個users表如下:

    id         yhm             xm

    1          001             小唐

    2          002             小李

    3          003             小張

    select wm_concat(yhm) 用戶名, wm_concat(xm) 姓名  from users

    執行結果為:

    用戶名                 姓名

    001,002,003      小唐,小李,小張


    posted @ 2012-03-23 16:38 yuhaibo736 閱讀(919) | 評論 (0)編輯 收藏

        public static String lastMonFirstDay(){ 
            Calendar cal = Calendar.getInstance(); 
            int year = cal.get(Calendar.YEAR); 
            int month = cal.get(Calendar.MONTH) + 1; 
            cal.set(Calendar.DAY_OF_MONTH, 1); 
            cal.add(Calendar.DAY_OF_MONTH, -1); 
            int day = cal.get(Calendar.DAY_OF_MONTH); 
            String months = ""; 
            String days = ""; 
            if (month > 1) { 
                month--; 
            } else { 
                year--; 
                month = 12; 
            } 
            if (!(String.valueOf(month).length() > 1)) { 
                months = "0" + month; 
            } else { 
                months = String.valueOf(month); 
            } 
            if (!(String.valueOf(day).length() > 1)) { 
                days = "0" + day; 
            } else { 
                days = String.valueOf(day); 
            } 
            String firstDay = "" + year + "-" + months + "-01"; 
            String[] lastMonth = new String[2]; 
            lastMonth[0] = firstDay; 
            return firstDay; 
        } 
         
        public static String lastMonLastDay(){ 
            Calendar cal = Calendar.getInstance(); 
            int year = cal.get(Calendar.YEAR); 
            int month = cal.get(Calendar.MONTH) + 1; 
            cal.set(Calendar.DAY_OF_MONTH, 1); 
            cal.add(Calendar.DAY_OF_MONTH, -1); 
            int day = cal.get(Calendar.DAY_OF_MONTH); 
            String months = ""; 
            String days = ""; 
            if (month > 1) { 
                month--; 
            } else { 
                year--; 
                month = 12; 
            } 
            if (!(String.valueOf(month).length() > 1)) { 
                months = "0" + month; 
            } else { 
                months = String.valueOf(month); 
            } 
            if (!(String.valueOf(day).length() > 1)) { 
                days = "0" + day; 
            } else { 
                days = String.valueOf(day); 
            } 
            String lastDay = "" + year + "-" + months + "-" + days; 
            String[] lastMonth = new String[2]; 
            lastMonth[1] = lastDay; 
            return lastDay; 
        }

    posted @ 2012-03-05 14:36 yuhaibo736 閱讀(644) | 評論 (0)編輯 收藏

    首先導入使用jar包:activation.jar,commons-logging-1.0.4.jar,mail.jar,spring.jar

     

    1、使用xml配置javamail:
    在classpath底下新建application-mail.xml,內容如下:

    Xml代碼 復制代碼 收藏代碼
    1. <?xml version="1.0" encoding="UTF-8"?>  
    2. <beans xmlns="http://www.springframework.org/schema/beans"  
    3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    4.        xmlns:aop="http://www.springframework.org/schema/aop"  
    5.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
    6.        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">  
    7.     <!-- 注意:這里的參數(如用戶名、密碼)都是針對郵件發送者的 -->  
    8.     <bean id="mailSender"  
    9.   class="org.springframework.mail.javamail.JavaMailSenderImpl">  
    10.         <property name="host">  
    11.             <value>stmp.163.com</value>  
    12.         </property>  
    13.         <property name="javaMailProperties">  
    14.             <props>  
    15.                 <prop key="mail.smtp.auth">true</prop>  
    16.                 <prop key="mail.smtp.timeout">25000</prop>  
    17.             </props>  
    18.         </property>  
    19.         <property name="username">  
    20.             <value>xxxx@163.com</value>  
    21.         </property>  
    22.         <property name="password">  
    23.             <value>xxxxxx</value>  
    24.         </property>  
    25.     </bean>  
    26. </beans>  

      或者把以上的Beans配置到applicaiont.xml里面也可以。

     

    2、發送Email類:

    Java代碼 復制代碼 收藏代碼
    1. public class SendMail {   
    2.  public ApplicationContext ctx = null;   
    3.  public SendMail() {   
    4.   //獲取上下文   
    5.   ctx = new ClassPathXmlApplicationContext("applicationContext-mail.xml");   
    6.  }   
    7.  public void send() {   
    8.   //獲取JavaMailSender bean   
    9.   JavaMailSender sender = (JavaMailSender) ctx.getBean("mailSender");   
    10.   SimpleMailMessage mail = new SimpleMailMessage(); //<SPAN style="COLOR: #ff0000">注意SimpleMailMessage只能用來發送text格式的郵件</SPAN>   
    11.   
    12.   
    13.   try {   
    14.    mail.setTo("xxx@qq.com");//接受者   
    15.    mail.setFrom("xxxx@163.com");//發送者,這里還可以另起Email別名,不用和xml里的username一致   
    16.    mail.setSubject("spring mail test!");//主題   
    17.    mail.setText("springMail的簡單發送測試");//郵件內容   
    18.    sender.send(mail);   
    19.   } catch (Exception e) {   
    20.    e.printStackTrace();   
    21.   }   
    22.  }  

     

     發送html格式的Email:

     

    Java代碼 復制代碼 收藏代碼
    1. public class SendMail {   
    2.  public ApplicationContext ctx = null;   
    3.  public SendMail() {   
    4.   //獲取上下文   
    5.   ctx = new ClassPathXmlApplicationContext("applicationContext.xml");   
    6.  }   
    7.  public void send() {   
    8.   //獲取JavaMailSender bean   
    9.   JavaMailSender sender = (JavaMailSender) ctx.getBean("mailSender");   
    10.   JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();   
    11.   MimeMessage mailMessage = senderImpl.createMimeMessage();   
    12.   //設置utf-8或GBK編碼,否則郵件會有亂碼   
    13.   MimeMessageHelper messageHelper = new MimeMessageHelper(mailMessage,true,"utf-8");   
    14.   try {   
    15.    messageHelper.setTo(email.getEmail());//接受者      
    16.    messageHelper.setFrom("xxx@163.com");//發送者   
    17.    messageHelper.setSubject("測試郵件");//主題   
    18.    //郵件內容,注意加參數true,表示啟用html格式   
    19.    messageHelper.setText("<html><head></head><body><h1>hello!!chao.wang</h1></body></html>",true);   
    20.    sender.send(mailMessage);   
    21.   } catch (Exception e) {   
    22.    e.printStackTrace();   
    23.   }   
    24.  }  
     

    發送html格式并帶有附件的Email:

    Java代碼 復制代碼 收藏代碼
    1. public class SendMail {   
    2.  public ApplicationContext ctx = null;   
    3.  public SendMail() {   
    4.   //獲取上下文   
    5.   ctx = new ClassPathXmlApplicationContext("applicationContext.xml");   
    6.  }   
    7.  public void send() {   
    8.   //獲取JavaMailSender bean   
    9.   JavaMailSender sender = (JavaMailSender) ctx.getBean("mailSender");   
    10.   JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();   
    11.   MimeMessage mailMessage = senderImpl.createMimeMessage();   
    12.   //設置utf-8或GBK編碼,否則郵件會有亂碼   
    13.   MimeMessageHelper messageHelper = new MimeMessageHelper(mailMessage,true,"utf-8");   
    14.   try {   
    15.    messageHelper.setTo(email.getEmail());//接受者      
    16.    messageHelper.setFrom("xxx@163.com");//發送者   
    17.    messageHelper.setSubject("測試郵件");//主題   
    18.    //郵件內容,注意加參數true   
    19.    messageHelper.setText("<html><head></head><body><h1>hello!!chao.wang</h1></body></html>",true);   
    20.    //附件內容   
    21.    messageHelper.addInline("a"new File("E:/xiezi.jpg"));   
    22.    messageHelper.addInline("b"new File("E:/logo.png"));    
    23.    File file=new File("E:/測試中文文件.rar");     
    24.    // 這里的方法調用和插入圖片是不同的,使用MimeUtility.encodeWord()來解決附件名稱的中文問題   
    25.    messageHelper.addAttachment(MimeUtility.encodeWord(file.getName()), file);    
    26.    sender.send(mailMessage);   
    27.   } catch (Exception e) {   
    28.    e.printStackTrace();   
    29.   }   
    30.  }  

    posted @ 2012-03-02 14:34 yuhaibo736 閱讀(9349) | 評論 (4)編輯 收藏

    1. public class TestApp {   
    2.   
    3.     public static void main(String[] args) {   
    4.         //List-->數組   
    5.         List<String> list = new ArrayList<String>();   
    6.         list.add("蹇偉");   
    7.         list.add("Jerval");   
    8.         list.add("杰威");   
    9.         Object[] objects = list.toArray();//返回Object數組   
    10.         System.out.println("objects:"+Arrays.toString(objects));   
    11.         String[] strings1 = new String[list.size()];   
    12.         list.toArray(strings1);//將轉化后的數組放入已經創建好的對象中   
    13.         System.out.println("strings1:"+Arrays.toString(strings1));   
    14.         String[] strings2 = list.toArray(new String[0]);//將轉化后的數組賦給新對象   
    15.         System.out.println("strings2:"+Arrays.toString(strings2));   
    16.         //數組-->List   
    17.         String[] ss = {"JJ","KK"};   
    18.         List<String> list1 = Arrays.asList(ss);   
    19.         List<String> list2 = Arrays.asList("AAA","BBB");   
    20.         System.out.println(list1);   
    21.         System.out.println(list2);   
    22.         //List-->Set   
    23.         List<String> list3 = new ArrayList<String>(new HashSet<String>());    
    24.         //Set-->List   
    25.         Set<String> set = new HashSet<String>(new ArrayList<String>());   
    26.         //數組-->Set   
    27.         String[] strs = {"AA","BB"};   
    28.         Set<String> set2 = new HashSet<String>(Arrays.asList(strs));   
    29.         System.out.println(set2);   
    30.         //Set-->數組   
    31.         Set<String> set3 = new HashSet<String>(Arrays.asList("PP","OO"));   
    32.         String[] strSet = new String[set3.size()];   
    33.         set3.toArray(strSet);   
    34.         System.out.println(Arrays.toString(strSet));   
    35.         //Map操作   
    36.         Map<String, String> map = new HashMap<String, String>();   
    37.         map.put("YYY""UUU");   
    38.         map.put("RRR""TTT");   
    39.         // 將鍵轉化為Set     
    40.         Set<String> mapKeySet = map.keySet();   
    41.         // 將值轉化為Set     
    42.         Set<String> mapValuesSet = new HashSet<String>(map.values());   
    43.         // 將值轉化為List     
    44.         List<String> mapValuesList = new ArrayList<String>(map.values());   
    45.   
    46.     }   
    47. }  

    posted @ 2012-02-20 15:00 yuhaibo736 閱讀(6134) | 評論 (0)編輯 收藏

    public Integer batchInsertEntitylist(final List<Entity> list) {

      return (Integer) this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {

       public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {

        executor.startBatch();
        int batch = 0;
        int count = 0;
        for (Entity entity: list) {
         executor.insert("insertEntitylist", entity);
         batch++;
         if (batch == 500) {
          executor.executeBatch();
          batch = 0;
         }
        }
        executor.executeBatch();
        count = 1;
        return count;
       }

      });
     }

    posted @ 2012-02-15 14:00 yuhaibo736 閱讀(2019) | 評論 (0)編輯 收藏

    ASCII碼表
      

    信息在計算機上是用二進制表示的,這種表示法讓人理解就很困難。因此計算機上都配有輸入和輸出設備,這些設備的主要目的就是,以一種人類可閱讀的形式將信息在這些設備上顯示出來供人閱讀理解。為保證人類和設備,設備和計算機之間能進行正確的信息交換,人們編制的統一的信息交換代碼,這就是ASCII碼表,它的全稱是“美國信息交換標準代碼”。

     

    八進制 十六進制 十進制 字符 八進制 十六進制 十進制 字符
    00 00 0 nul 100 40 64 @
    01 01 1 soh 101 41 65 A
    02 02 2 stx 102 42 66 B
    03 03 3 etx 103 43 67 C
    04 04 4 eot 104 44 68 D
    05 05 5 enq 105 45 69 E
    06 06 6 ack 106 46 70 F
    07 07 7 bel 107 47 71 G
    10 08 8 bs 110 48 72 H
    11 09 9 ht 111 49 73 I
    12 0a 10 nl 112 4a 74 J
    13 0b 11 vt 113 4b 75 K
    14 0c 12 ff 114 4c 76 L
    15 0d 13 er 115 4d 77 M
    16 0e 14 so 116 4e 78 N
    17 0f 15 si 117 4f 79 O
    20 10 16 dle 120 50 80 P
    21 11 17 dc1 121 51 81 Q
    22 12 18 dc2 122 52 82 R
    23 13 19 dc3 123 53 83 S
    24 14 20 dc4 124 54 84 T
    25 15 21 nak 125 55 85 U
    26 16 22 syn 126 56 86 V
    27 17 23 etb 127 57 87 W
    30 18 24 can 130 58 88 X
    31 19 25 em 131 59 89 Y
    32 1a 26 sub 132 5a 90 Z
    33 1b 27 esc 133 5b 91 [
    34 1c 28 fs 134 5c 92 \
    35 1d 29 gs 135 5d 93 ]
    36 1e 30 re 136 5e 94 ^
    37 1f 31 us 137 5f 95 _
    40 20 32 sp 140 60 96 '
    41 21 33 ! 141 61 97 a
    42 22 34 " 142 62 98 b
    43 23 35 # 143 63 99 c
    44 24 36 $ 144 64 100 d
    45 25 37 % 145 65 101 e
    46 26 38 & 146 66 102 f
    47 27 39 ` 147 67 103 g
    50 28 40 ( 150 68 104 h
    51 29 41 ) 151 69 105 i
    52 2a 42 * 152 6a 106 j
    53 2b 43 + 153 6b 107 k
    54 2c 44 , 154 6c 108 l
    55 2d 45 - 155 6d 109 m
    56 2e 46 . 156 6e 110 n
    57 2f 47 / 157 6f 111 o
    60 30 48 0 160 70 112 p
    61 31 49 1 161 71 113 q
    62 32 50 2 162 72 114 r
    63 33 51 3 163 73 115 s
    64 34 52 4 164 74 116 t
    65 35 53 5 165 75 117 u
    66 36 54 6 166 76 118 v
    67 37 55 7 167 77 119 w
    70 38 56 8 170 78 120 x
    71 39 57 9 171 79 121 y
    72 3a 58 : 172 7a 122 z
    73 3b 59 ; 173 7b 123 {
    74 3c 60 < 174 7c 124 |
    75 3d 61 = 175 7d 125 }
    76 3e 62 > 176 7e 126 ~
    77 3f 63 ? 177 7f 127 del

    posted @ 2012-02-13 17:30 yuhaibo736 閱讀(163) | 評論 (0)編輯 收藏

       $j.fn.numeral = function() {
            $j(this).css("ime-mode", "disabled");
            this.bind("keypress",function() {
                if (event.keyCode == 46) {
                    if (this.value.indexOf(".") != -1) {
                        return false;
                    }
                } else {
                    return event.keyCode >= 46 && event.keyCode <= 57;
                }
            });
            this.bind("blur", function() {
                if (this.value.lastIndexOf(".") == (this.value.length - 1)) {
                    this.value = this.value.substr(0, this.value.length - 1);
                } else if (isNaN(this.value)) {
                    this.value = "";
                }
            });
            this.bind("paste", function() {
                var s = clipboardData.getData('text');
                if (!/\D/.test(s));
                value = s.replace(/^0*/, '');
                return false;
            });
            this.bind("dragenter", function() {
                return false;
            });
            this.bind("keyup", function() {
            if (/(^0+)/.test(this.value)) {
                this.value = this.value.replace(/^0*/, '');
                }
            });
        };

    posted @ 2012-02-13 17:25 yuhaibo736 閱讀(1210) | 評論 (2)編輯 收藏

     第一種:傳入參數僅有數組
           <select id="GetEmailList_Test"  resultClass="EmailInfo_">
                select *
                from MailInfo with (nolock)
                where ID in
                    <iterate open="(" close=")" conjunction="," >
                        #[]#
                    </iterate>
            </select>
    調用
                string[] strValue = new string[] { "1", "2", "3" };
                Reader.QueryForList<EmailInfoModel>("WebApp_Ibatisnet.dao.GetEmailList_Test", strValue );

           第二種:傳入參數有數組,且有其他數據
            <select id="GetEmailList_Test3" parameterClass="TestIn" resultClass="EmailInfo_">
                select  top(#Count#)*
                from MailInfo with (nolock)
                where ID in
                <iterate open="(" close=")" conjunction="," property="ArrValue" >
                    #ArrValue[]#
                </iterate>
            </select>
    調用
                TestIn ti = new TestIn();
                ti.Count = 1;
                ti.ArrValue = strValue;
                return Reader.QueryForList<EmailInfoModel>("WebApp_Ibatisnet.dao.GetEmailList_Test3", ti);
    實體類:
       public class TestIn
        {
            private int count;
            public int Count
            {
                get { return count; }
                set { count = value; }
            }
            private string[] arrValue;
            public string[] ArrValue
            {
                get { return arrValue; }
                set { arrValue = value; }
            }
        }

           第三種:in后面的數據確定,使用string傳入
            <select id="GetEmailList_Test2" parameterClass="TestIn" resultClass="EmailInfo_">
                select *
                from MailInfo with (nolock)
                where ID in
                ($StrValue$)
            </select>
    調用
                    Reader.QueryForList<EmailInfoModel>("WebApp_Ibatisnet.dao.GetEmailList_Test2", "1,2,3");


    其他信息:
    Iterate的屬性:
    prepend -可被覆蓋的SQL語句組成部分,添加在語句的前面(可選)
    property -類型為java.util.List的用于遍歷的元素(必選)
    open -整個遍歷內容體開始的字符串,用于定義括號(可選)
    close -整個遍歷內容體結束的字符串,用于定義括號(可選)
    conjunction -每次遍歷內容之間的字符串,用于定義AND或OR(可選)
    <iterate>遍歷類型為java.util.List的元素。

    posted @ 2012-02-03 10:11 yuhaibo736 閱讀(16612) | 評論 (1)編輯 收藏

    //獲取客戶端ip地址

             public String getIpAddr(HttpServletRequest request) {

                    String ip = request.getHeader("x-forwarded-for");

                    if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

                        ip = request.getHeader("Proxy-Client-IP");

                    }

                    if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

                        ip = request.getHeader("WL-Proxy-Client-IP");

                    }

                    if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

                        ip = request.getRemoteAddr();

                    }

                    return ip;

              }

     

    //獲取服務器ip地址

             InetAddress inet = InetAddress.getLocalHost();

             String hostAddress=inet.getHostAddress();

    posted @ 2012-01-17 11:01 yuhaibo736 閱讀(823) | 評論 (0)編輯 收藏

    集合的一個很重要的操作---遍歷,學習了三種遍歷方法,三種方法各有優缺點~~
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package cn.tsp2c.liubao;
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.Set;
    import java.util.TreeMap;
    /**
     *
     * @author Administrator
     */
    public class TestMap {
        public static void main(String[] args) {
            Map<String, Student> map = new HashMap<String, Student>();
            Student s1 = new Student("宋江", "1001", 38);
            Student s2 = new Student("盧俊義", "1002", 35);
            Student s3 = new Student("吳用", "1003", 34);
           
            map.put("1001", s1);
            map.put("1002", s2);
            map.put("1003", s3);
            Map<String, Student> subMap = new HashMap<String, Student>();
            subMap.put("1008", new Student("tom", "1008", 12));
            subMap.put("1009", new Student("jerry", "1009", 10));
            map.putAll(subMap);
            work(map);
            workByKeySet(map);
            workByEntry(map);
        }
      //最常規的一種遍歷方法,最常規就是最常用的,雖然不復雜,但很重要,這是我們最熟悉的,就不多說了!!
        public static void work(Map<String, Student> map) {
            Collection<Student> c = map.values();
            Iterator it = c.iterator();
            for (; it.hasNext();) {
                System.out.println(it.next());
            }
        }
      //利用keyset進行遍歷,它的優點在于可以根據你所想要的key值得到你想要的 values,更具靈活性!!
        public static void workByKeySet(Map<String, Student> map) {
            Set<String> key = map.keySet();
            for (Iterator it = key.iterator(); it.hasNext();) {
                String s = (String) it.next();
                System.out.println(map.get(s));
            }
        }
      //比較復雜的一種遍歷在這里,呵呵~~他很暴力哦,它的靈活性太強了,想得到什么就能得到什么~~
        public static void workByEntry(Map<String, Student> map) {
            Set<Map.Entry<String, Student>> set = map.entrySet();
            for (Iterator<Map.Entry<String, Student>> it = set.iterator(); it.hasNext();) {
                Map.Entry<String, Student> entry = (Map.Entry<String, Student>) it.next();
                System.out.println(entry.getKey() + "--->" + entry.getValue());
            }
        }
    }
    class Student {
        private String name;
        private String id;
        private int age;
        public Student(String name, String id, int age) {
            this.name = name;
            this.id = id;
            this.age = age;
        }
        @Override
        public String toString() {
            return "Student{" + "name=" + name + "id=" + id + "age=" + age + '}';
        }
    }

    posted @ 2012-01-17 10:58 yuhaibo736 閱讀(214) | 評論 (0)編輯 收藏

    僅列出標題
    共5頁: 上一頁 1 2 3 4 5 下一頁 
    主站蜘蛛池模板: 女人18毛片免费观看| 免费大片黄手机在线观看| 亚洲中文字幕一二三四区苍井空| 久久久久免费看黄A片APP| 国产亚洲情侣久久精品| 在线视频网址免费播放| 免费久久精品国产片香蕉| 国产一区二区三区免费观在线 | 色五月五月丁香亚洲综合网| 亚洲欧洲自拍拍偷精品 美利坚 | 午夜无码A级毛片免费视频| 国产亚洲精品不卡在线| 特a级免费高清黄色片| 亚洲最新永久在线观看| 99热在线日韩精品免费| 亚洲 欧洲 日韩 综合在线| 99精品全国免费观看视频| 久久精品免费网站网| 自拍日韩亚洲一区在线| 久久久亚洲欧洲日产国码农村| 日韩高清在线免费看| 成a人片亚洲日本久久| 亚洲色欲www综合网| 久久久久亚洲精品天堂久久久久久 | 日韩高清在线免费观看| 88xx成人永久免费观看| wwwxxx亚洲| 久久九九亚洲精品| 国产午夜影视大全免费观看 | 免费被黄网站在观看| 少妇人妻偷人精品免费视频| 无码精品人妻一区二区三区免费| 91亚洲性爱在线视频| 亚洲AV无码第一区二区三区| 全亚洲最新黄色特级网站| 成年女人毛片免费观看97| 色片在线免费观看| 无码av免费一区二区三区试看| 久久www免费人成看国产片| 国产午夜亚洲精品不卡电影| 亚洲日韩AV一区二区三区中文|