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

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

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

    繼續(xù)關(guān)注我的C語(yǔ)言學(xué)習(xí)博客

    林臨的地盤

    java學(xué)習(xí)博客
    posts - 44, comments - 28, trackbacks - 0, articles - 0
      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    2007年2月8日

    struts2的s:iterator 可以遍歷 數(shù)據(jù)棧里面的任何數(shù)組,集合等等 以下幾個(gè)簡(jiǎn)單的demo:
    s:iterator 標(biāo)簽有3個(gè)屬性:
        value:被迭代的集合
        id   :指定集合里面的元素的id
        status 迭代元素的索引
    1:jsp頁(yè)面定義元素寫法 數(shù)組或list

    <s:iterator value="{'1','2','3','4','5'}" id='number'>
        <s:property value='number'/>A
    </s:iterator>
    打印結(jié)果為: 1A2A3A4A5A
    2:索引的用法
    如果指定了status,每次的迭代數(shù)據(jù)都有IteratorStatus的實(shí)例,它有以下幾個(gè)方法
    int getCount()返回當(dāng)前迭代了幾個(gè)元素
    int getIndex()返回當(dāng)前元素索引
    boolean isEven()當(dāng)然的索引是否偶數(shù)
    boolean isFirst()當(dāng)前是否第一個(gè)元素
    boolean isLast()
    boolean isOdd()當(dāng)前元素索引是否奇數(shù)
    <s:iterator value="{'a','b','c'}" id='char' status='st'>
        <s:if test="#st.Even">
            現(xiàn)在的索引是奇數(shù)為:<s:property value='#st.index'/>
        </s:if>
        當(dāng)前元素值:<s:property value='char'/>
    </s:iterator>
    3:遍歷map
    value可以直接定義為:
    value="#{"1":"a","2":"b"}"
    每個(gè)元素以都好隔開(kāi)。元素之間的key和value 冒號(hào)隔開(kāi)
    value也可以是數(shù)據(jù)棧里面的java.util.Map對(duì)象
    遍歷寫法如下:
    <s:iterator value="map" id="id" status="st">
         key : <s:property value='key'/>
         value:<s:property vlaue='value'/>
    </s:iterator>
    當(dāng)然key 和value 都可以使java 的 Object
    3:遍歷數(shù)據(jù)棧.簡(jiǎn)單的List類,
    List<Attr>
    class Attr{String attrName;String getAttrName(){return "123";}}
    <s:iterator value="label" id="id">
        <s:property value="#id.attrName" />
    </s:iterator>
    當(dāng)然value 還可以寫成 value="%{label}" label可以有.操作
    label的屬性List 可以寫成value="%{label.list}" 相當(dāng)于:getLabel().getList();
    4:遍歷2個(gè)list;
    List<AttrName> attrN {color,size,style}
    List<AttrValue> attrV {red,20,gay}
    這2個(gè)list的元素是一一對(duì)應(yīng)的,一個(gè)attrN對(duì)應(yīng)一個(gè)attrV
    <s:iterator value="%{attrN }" id="id"   status="status">
    index    is : <s:property value='status.index'/>
    attrName is : <s:property value='id'/> or <s:property value='%{id}'/>
    attrName is : <s:property value='%{attrV[#status.index]}'/>
    </s:iterator>  
    轉(zhuǎn)自:http://m.tkk7.com/Reg/archive/2009/11/20/303085.html

    posted @ 2012-06-18 17:11 lubaolin 閱讀(845) | 評(píng)論 (0)編輯 收藏

    點(diǎn)擊“開(kāi)始→運(yùn)行”,在彈出的“運(yùn)行”對(duì)話框中輸入“REGSVR32 /n /i:u shell32”(不含雙引號(hào)),然后回車,片刻后會(huì)彈出“shell32中的DllInstall成功”對(duì)話框,“顯示桌面”按鈕就可以完美歸來(lái)了

    posted @ 2011-04-21 09:11 lubaolin 閱讀(376) | 評(píng)論 (0)編輯 收藏

         摘要: HTML字符實(shí)體(Character Entities),轉(zhuǎn)義字符串(Escape Sequence) 為什么要用轉(zhuǎn)義字符串? HTML中<,>,&等有特殊含義(<,>,用于鏈接簽,&用于轉(zhuǎn)義),不能直接使用。這些符號(hào)是不顯示在我們最終看到的網(wǎng)頁(yè)里的,那如果我們希望在網(wǎng)頁(yè)中顯示這些符號(hào),該怎么辦呢? 這就要說(shuō)到HTML轉(zhuǎn)義字符串(Esca...  閱讀全文

    posted @ 2010-09-07 18:30 lubaolin 閱讀(8838) | 評(píng)論 (0)編輯 收藏

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Date;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import net.sf.jazzlib.ZipEntry;
    import net.sf.jazzlib.ZipOutputStream;

    public class BatchDownload extends HttpServlet {

     public BatchDownload() {
      super();
     }

     public void doGet(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
      response.setContentType("APPLICATION/OCTET-STREAM");
      response.setHeader("Content-Disposition","attachment; filename="+this.getZipFilename());
      System.out.println("in BatchDownload................");
      ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());  
         File[] files = new File[2];
         files[0]=new File("c:/zip/文件A.doc");
         files[1]=new File("c:/zip/文件B.doc");
         zipFile(files, "", zos);  
         zos.flush();  
         zos.close();  

     }
     private void zipFile(File[] subs, String baseName, ZipOutputStream zos) throws IOException {    
          for (int i=0;i<subs.length;i++) {
           File f=subs[i];
           zos.putNextEntry(new ZipEntry(baseName + f.getName()));  
           FileInputStream fis = new FileInputStream(f);  
           byte[] buffer = new byte[1024];  
           int r = 0;  
           while ((r = fis.read(buffer)) != -1) {  
               zos.write(buffer, 0, r);  
           }  
           fis.close();
          }
     }
     private String getZipFilename(){
      Date date=new Date();
      String s=date.getTime()+".zip";
      return s;
     }

     public void doPost(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
      this.doGet(request, response);
     }
    }

    posted @ 2009-10-22 14:30 lubaolin 閱讀(721) | 評(píng)論 (0)編輯 收藏

    將listener.ora中的(PROGRAM = extproc)這句注釋掉就可以了。去網(wǎng)上找過(guò),extproc是一個(gè)擴(kuò)展的程序調(diào)用接口協(xié)議,  連接和調(diào)用外部的操作系統(tǒng)程序或進(jìn)程用時(shí)會(huì)用到。

    轉(zhuǎn)自:http://blog.csdn.net/chenjuntj2007/archive/2009/07/04/4321640.aspx

    posted @ 2009-09-21 17:19 lubaolin 閱讀(21241) | 評(píng)論 (3)編輯 收藏

    //創(chuàng)建臨時(shí)表空間

    create temporary tablespace test_temp
    tempfile 'E:\oracle\product\10.2.0\oradata\testserver\test_temp01.dbf'
    size 32m
    autoextend on
    next 32m maxsize 2048m
    extent management local;

    //創(chuàng)建數(shù)據(jù)表空間
    create tablespace test_data
    logging
    datafile 'E:\oracle\product\10.2.0\oradata\testserver\test_data01.dbf'
    size 32m
    autoextend on
    next 32m maxsize 2048m
    extent management local;

    //創(chuàng)建用戶并指定表空間
    create user username identified by password
    default tablespace test_data
    temporary tablespace test_temp;

    //給用戶授予權(quán)限

    grant connect,resource to username;

    //以后以該用戶登錄,創(chuàng)建的任何數(shù)據(jù)庫(kù)對(duì)象都屬于test_temp 和test_data表空間,這就不用在每創(chuàng)建一個(gè)對(duì)象給其指定表空間了。

    轉(zhuǎn)載:http://virgos.javaeye.com/blog/337976

    posted @ 2009-07-23 10:35 lubaolin 閱讀(367) | 評(píng)論 (0)編輯 收藏

    struts2+spring2.x+hibernate3.x 懶加載異常:org.hibernate.LazyInitializationException: failed to lazily initialize

    Hibernate的Lazy初始化1:n關(guān)系時(shí),必須保證是在同一個(gè)Session內(nèi)部使用這個(gè)關(guān)系集合,不然Hiernate將拋出異常:org.hibernate.LazyInitializationException: failed to lazily initialize of....
    兩種處理方法:
    一、設(shè)置lazy=false,此方法不再累述。
    二、用OpenSessionInViewFilter過(guò)濾器,注意hibernateFilter過(guò)濾器和struts2過(guò)濾器在映射時(shí)的先后順序。同時(shí)要配置事物處理,否則會(huì)導(dǎo)致session處于只讀狀態(tài)而不能做修改、刪除的動(dòng)作。
    即在web.xml文件中如下配置:
         <!-- Spring ApplicationContext配置文件的加載目錄。 -->  
     <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath*:spring/applicationContext.xml</param-value>
     </context-param>

     <!-- 解決延遲加載的問(wèn)題 -->
     <filter>
      <filter-name>hibernateFilter</filter-name>
      <filter-class>
       org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
      </filter-class>
     </filter>
     
     <!-- 繼承Struts2的FilterDispatcher類,具備GBK等編碼設(shè)定功能與struts2的action過(guò)濾功能。 -->
     <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
       com.iman.nrms.opm.web.common.FilterDispatcher
      </filter-class>
      <init-param>
       <param-name>encoding</param-name>
       <param-value>GBK</param-value>
      </init-param>
     </filter>
     <filter>
             <filter-name>struts-cleanup</filter-name>
             <filter-class>
                 org.apache.struts2.dispatcher.ActionContextCleanUp
             </filter-class>
         </filter>
     
     <filter-mapping>
      <filter-name>hibernateFilter</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
     
     <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
     
     <filter-mapping>
      <filter-name>struts-cleanup</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>

    Hibernate 允許對(duì)關(guān)聯(lián)對(duì)象、屬性進(jìn)行延遲加載,但是必須保證延遲加載的操作限于同一個(gè) Hibernate Session 范圍之內(nèi)進(jìn)行。如果 Service 層返回一個(gè)啟用了延遲加載功能的領(lǐng)域?qū)ο蠼o Web 層,當(dāng) Web 層訪問(wèn)到那些需要延遲加載的數(shù)據(jù)時(shí),由于加載領(lǐng)域?qū)ο蟮?Hibernate Session 已經(jīng)關(guān)閉,這些導(dǎo)致延遲加載數(shù)據(jù)的訪問(wèn)異常。而Spring為我們提供的OpenSessionInViewFilter過(guò)濾器為我們很好的解決了這個(gè)問(wèn)題。OpenSessionInViewFilter的主要功能是使每個(gè)請(qǐng)求過(guò)程綁定一個(gè) Hibernate Session,即使最初的事務(wù)已經(jīng)完成了,也可以在 Web 層進(jìn)行延遲加載的操作。OpenSessionInViewFilter 過(guò)濾器將 Hibernate Session 綁定到請(qǐng)求線程中,它將自動(dòng)被 Spring 的事務(wù)管理器探測(cè)到。所以 OpenSessionInViewFilter 適用于 Service 層使用HibernateTransactionManager 或 JtaTransactionManager 進(jìn)行事務(wù)管理的環(huán)境,也可以用于非事務(wù)只讀的數(shù)據(jù)操作中。
    request-->open session-->打開(kāi)連接、開(kāi)始事務(wù)-->持久操作-->渲染(關(guān)閉連接、session)-->response 其中一些過(guò)程省略了,不是很關(guān)心。

     

    引自:http://blog.csdn.net/fhwbj/archive/2009/03/25/4022805.aspx

    posted @ 2009-07-03 16:19 lubaolin 閱讀(2664) | 評(píng)論 (0)編輯 收藏

    1、選擇Help -> Software Updates -> Find and Install...-> Search for new features to install ->New remote site...
    Name: "Spket", Url: "http://www.spket.com/update/"下載完畢重啟 Eclipse

    2、Window -> Preferences -> Spket -> JavaScript Profiles -> New ;
    輸入“ExtJS”點(diǎn)擊OK;
    選擇“ExtJS” 并點(diǎn)擊“Add Library”然后在下拉條中選取“ExtJS”;
    選擇 “ExtJS”并點(diǎn)擊“Add File”,然后在你的./ext-2.x/source目錄中選取“ext.jsb” 文件;

    3、設(shè)置新的ExtJS Profile,選中并點(diǎn)擊“JavaScript Profiles” 對(duì)話框右手邊的“Defalut”按鈕;

    4、JS打開(kāi)方式為 Window -> Preferences ->General-> Editors-> File...選擇JS  為 Spket JavaScript Editor(default)

    posted @ 2009-04-06 22:20 lubaolin 閱讀(920) | 評(píng)論 (0)編輯 收藏

    半年前,報(bào)考了系統(tǒng)分析師,也沒(méi)怎么看書,只是抱著試試水有多深的想法去考的,結(jié)果既在我意料之中,也在我意料之外,得了個(gè)39/33/39,只差6/12/6分就可以通過(guò)了,尤其是論文,居然得了39分,看來(lái)還是有希望的,所以決定再次沖擊,并以此做為平臺(tái),練習(xí)論文寫作,假如寫一篇論文就和寫一篇日記一樣手到擒來(lái)...........

    posted @ 2008-07-21 14:34 lubaolin 閱讀(401) | 評(píng)論 (0)編輯 收藏

    SQL> select * from t1;

            N1 V1                NID
    ---------- ---------- ----------
             1 aa                 61
             2 aa                 62
             3 bb                 83
             4 aa                 64

    SQL> select exp(sum(ln(nid))) from t1 where v1='aa';

    EXP(SUM(LN(NID)))
    -----------------
               242048

    已用時(shí)間:  00: 00: 00.02

    驗(yàn)證一下:)
    SQL> select 61*62*64 from dual;

      61*62*64
    ----------
        242048

    已用時(shí)間:  00: 00: 00.00

    先分組然后求積
    SQL> select exp(sum(ln(nid))) from t1 group by v1;

    EXP(SUM(LN(NID)))
    -----------------
               242048
                   83


    oracle 這東東挺有意思.
    轉(zhuǎn)自:http://blog.sina.com.cn/s/blog_54eeb5d901000ae5.html

    posted @ 2008-07-21 14:26 lubaolin 閱讀(1067) | 評(píng)論 (0)編輯 收藏

    Spring的依賴關(guān)系
    依賴關(guān)系分組
    JAR文件
    說(shuō) 明
    ant
    ant.jar, ant-junit.jar, ant-launcher.jar
    Spring采用Apache Ant作為其構(gòu)建工具,還用來(lái)完成大量其它任務(wù)如文檔生成和測(cè)試執(zhí)行等。運(yùn)行時(shí)Ant根本不起作用,因此發(fā)布應(yīng)用時(shí)無(wú)需包含該JAR文件。
    aopalliance
    aopalliance.jar
    AOP Alliance(http://aopalliance.sourceforge.net/)是個(gè)聯(lián)合的開(kāi)源協(xié)作組織,在多個(gè)項(xiàng)目間進(jìn)行協(xié)作以期提供一套標(biāo)準(zhǔn)的AOP Java接口(interface)。 Spring AOP就是基于AOP Alliance標(biāo)準(zhǔn)API實(shí)現(xiàn)的。如果你打算使用Spring的AOP或基于AOP的任何特性,只需這個(gè)JAR文件。
    axis
    axis.jar, saaj.jar, wsdl4j.jar
    Spring采用Apache Axis項(xiàng)目來(lái)支持Spring遠(yuǎn)程調(diào)用里的JAXRPC功能。如果使用JAXRPC Remoting,那么只需要這些文件。
    caucho
    burlap-2.1.12.jar, hessian-2.1.12.jar
    Spring遠(yuǎn)程調(diào)用(remoting)對(duì)大量不同種類的協(xié)議包括Caucho的Burlap和Hessian提供了支持。要用哪個(gè)協(xié)議就包含這個(gè)分組里相應(yīng)的JAR文件。
    cglib
    cglib-full-2.0.2.jar
    CGLIB用來(lái)生成動(dòng)態(tài)代理類(dynamic proxy classes),供核心DI和AOP實(shí)現(xiàn)之用。由于大量Spring功能的實(shí)現(xiàn)都要用到CGLIB,因此你的應(yīng)用幾乎總需包含CGLIB。
    cos
    cos.jar
    COS代表com.oreilly.servlet,是個(gè)實(shí)用類的集合,對(duì)Servlets和基于web的應(yīng)用很有用。Spring在兩個(gè)地方要用到COS:文件上傳處理和e-mail發(fā)送。不過(guò)在這兩種情形中,COS都只是實(shí)現(xiàn)選擇之一,因此只有選用COS而非其它實(shí)現(xiàn)方法時(shí),才需包含cos.jar。
    dom4j
    dom4j.jar
    使用Hibernate時(shí)dom4j不可或缺,因此如果你的應(yīng)用打算采用Hibernate實(shí)現(xiàn)ORM,就需要包含這個(gè)JAR文件。
    easymock
    easymock.jar, easymockclassextension.jar
    Spring的測(cè)試套件用到了EasyMock,因此只有構(gòu)建和運(yùn)行測(cè)試套件時(shí)才用到這個(gè)JAR,無(wú)需隨你的應(yīng)用一起發(fā)布。
    freemarker
    freemaker.jar
    Spring提供了FreeMarker模板引擎的包裝類,還為把FreeMarker模板用作web應(yīng)用的視圖提供了支持。只要使用FreeMarker,就需要這個(gè)JAR文件。
    hibernate
    ehcache.jar, hibernate2.jar, odmg.jar
    如果采用Spring的Hibernate集成和支持類,這些JAR文件不可或缺。如果使用其它ORM工具如iBATIS,則不需要這些JAR文件。如果使用Hibernate,則你的應(yīng)用還要包含CGLIB JAR文件。
    hsqldb
    hsqldb.jar
    Spring的示例應(yīng)用使用了hsqldb.jar文件。
    ibatis
    ibatis-common.jar , ibatis-sqlmap.jar, ibatis-sqlmap-2.jar
    使用Spring的iBATIS集成類時(shí),這些文件不可或缺;如果使用JDBC或其它ORM工具如Hibernate或JDO,則你的應(yīng)用不需要這些文件。
    itext
    itext-1.02b.jar
    Spring使用iText提供web層的PDF支持。只有你的web應(yīng)用需要生成PDF輸出時(shí)才需包含這個(gè)JAR文件。
    j2ee
    activation.jar, connector-api.jar, ejb.jar, jaxrpc.jar, jdbc2_0-stdext.jar, jms.jar, jstl.jar, jta.jar, mail.jar, servlet.jar, xml-apis.jar
    如左側(cè)所示,J2EE相關(guān)的各種不同JAR文件數(shù)量相當(dāng)可觀。如果你想要使用Spring郵件支持的JavaMail實(shí)現(xiàn),則需要activation.jar和mail.jar文件。要讓Hibernate使用JCA Connector則需connector-api.jar,使用Spring的EJB支持則需要ejb.jar,jms.jar用于Spring的JMS支持。對(duì)于web應(yīng)用,如果想要使用Spring JSTL支持則需要servlet.jar和jstl.jar。Spring遠(yuǎn)程調(diào)用里的JAXRPC支持需要jaxrpc.jar文件,jta.jar用于JTA事務(wù)支持。剩下兩個(gè)JAR文件jdbc2_0-stdext.jar和xml-apis.jar分別用于JDBC和XML配置支持,不過(guò)只有你使用1.3版本的JVM時(shí)才需要它們。
    jakarta
    jakarta-commons commons-attributes-api.jar, commons-attributes-compiler.jar, commons-beanutils.jar, commons-collections.jar, commons-dbcp.jar, commons-digester.jar, commons-discovery.jar, commons-fileupload.jar, commons-lang.jar, commons-logging.jar, commons-pool.jar, commons- validator.jar
    Spring使用了來(lái)自Jakarta Commons項(xiàng)目的大量組件。如果你想在應(yīng)用中使用源碼級(jí)元數(shù)據(jù)(metadata),就需要commons-attributes-api.jar,此外還需要commons-attributes-compiler.jar,以便將attributes編譯到應(yīng)用里。Struts要用到BeanUtils、Collections、Digester、Discovery,和Validator JAR文件,其中的Collections,Hibernate也會(huì)用到。使用DBCP連接池時(shí),Spring JDBC支持要用到DBCP,Pooling則對(duì)有些示例應(yīng)用不可或缺。如果想使用相應(yīng)的Spring包裝類來(lái)處理web應(yīng)用的文件上傳,則需要FileUpload。最后,Spring處處用到了Logging,因此需在所有基于Spring的應(yīng)用里包含這個(gè)JAR文件。
    jakarta-taglibs
    standard.jar
    這是Jakarta的JSTL實(shí)現(xiàn),一些Spring示例應(yīng)用使用了這個(gè)實(shí)現(xiàn)。
    jboss
    jboss-common-jdbc-wrapper.jar
    運(yùn)行在JBoss應(yīng)用服務(wù)器上的應(yīng)用使用Spring的JDBC類時(shí),這個(gè)JAR文件不可或缺。
    jdo
    jdo.jar
    提供Spring的JDO支持。
    jdom
    jdom.jar
    在Spring里使用iBATIS 1.3時(shí),JDOM不可或缺。本章介紹的iBATIS版本為2.0。
    jotm
    jotm.jar, xapool.jar
    如果你打算配合Spring事務(wù)抽象層一起使用JOTM,jotm.jar文件不可或缺。如果打算在自己的應(yīng)用里將XAPool用于連接池(connection pooling),則只需xapool.jar。
    junit
    junit.jar
    運(yùn)行時(shí)根本不需要JUnit;它只用來(lái)構(gòu)建和運(yùn)行測(cè)試套件。
    log4j
    log4j-1.2.8.jar
    如果想要使用Spring配置log4j日志記錄,這個(gè)文件不可或缺。
    poi
    poi-2.5.jar
    這個(gè)JAR可令Spring MVC框架支持Microsoft Excel輸出。
    quartz
    quartz.jar
    Spring基于Quartz的調(diào)度支持需要該JAR。
    regexp
    Jakarta-oro-2.0.7.jar
    使用正則表達(dá)式來(lái)指定AOP的切入點(diǎn)(pointcut)時(shí)需要這個(gè)JAR。第六章有更詳細(xì)的介紹。
    struts
    struts.jar
    欲配合Spring使用Struts構(gòu)建web應(yīng)用,Struts JAR必不可少。
    velocity
    velocity-1.4.jar, velocity-tools-generic-1.1.jar
    Spring提供了Velocity的包裝類使其支持DI,同時(shí)當(dāng)你在應(yīng)用中使用Velocity時(shí),還可減少需要編寫的代碼量。除此之外,Spring還提供了一些類,支持將Velocity用作web層里的視圖提供者(view provider)。只要使用了上述任意特性,都需在發(fā)布里包含Velocity JAR文件。
    xdoclet
    xjavadoc-1.0.jar
    Commons Attributes用這個(gè)JAR解析源代碼文件,然后提取屬性信息。如果使用了Spring Commons Attributes支持,須包含該JAR文件。

    posted @ 2007-08-13 02:39 lubaolin 閱讀(5348) | 評(píng)論 (0)編輯 收藏

    <a target=_self href="javascript:goUrl()">
        <span class="f14b">
        <script type="text/javascript">
         imgUrl1="/images/1.jpg";
         imgtext1="ite"
         imgLink1=escape("http://m.tkk7.com/linlin2005");
         imgUrl2="/images/2.jpg";
         imgtext2="ite"
         imgLink2=escape("http://m.tkk7.com/linlin2005");
         imgUrl3="/images/3.jpg";
         imgtext3="ite"
         imgLink3=escape("http://m.tkk7.com/linlin2005");
         imgUrl4="/images/4.jpg";
         imgtext4="ite"
         imgLink4=escape("http://m.tkk7.com/linlin2005");
         imgUrl5="/images/5.jpg";
         imgtext5="ite"
         imgLink5=escape("http://m.tkk7.com/linlin2005");
         var focus_width=134
         var focus_height=130
         var text_height=30
         var swf_height = focus_height+text_height
         
         var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4+"|"+imgUrl5
         var links=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4+"|"+imgLink5
         var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4+"|"+imgtext5
         document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6?0?0?0 width="'+ focus_width +'" height="'+ swf_height +'">');
         document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value=" http://www.webjx.com/js/focus.swf"><param name="quality" value="high"> <param name="bgcolor" value="#F0F0F0">');
         document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
         document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight=' +focus_height+'&textheight='+text_height+'">');
         document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight= '+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width ="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="    </script>
        </span></a><span id=focustext class=f14b> </span>

    posted @ 2007-08-07 17:56 lubaolin 閱讀(519) | 評(píng)論 (0)編輯 收藏

    有同事問(wèn)到在程序中怎樣知道數(shù)據(jù)庫(kù)表中那些字段是主鍵。當(dāng)時(shí)不知道,晚上回來(lái)看了看JDK的文檔。

           在使用JDBC來(lái)查詢數(shù)據(jù)庫(kù)的時(shí)候,通常的步驟是:

    1. 注冊(cè)驅(qū)動(dòng)程序

    2. 獲取數(shù)據(jù)庫(kù)連接

    3. 執(zhí)行查詢語(yǔ)句

    4. 關(guān)閉連接。

           在獲得數(shù)據(jù)庫(kù)連接后,就可以通過(guò)getMetaData()方法來(lái)獲取DatabaseMetaData;然后通過(guò)DatabaseMetaDatagetPrimaryKeys ()方法來(lái)獲取主鍵的信息。

           下面是我做的示例程序,該程序在JBuilder2005oracle8i下通過(guò):
    import java.sql.*;

    import javax.sql.*;

    public class TestJDBC {

        public TestJDBC() {

        }

     

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

            Connection con = null;

            Statement st = null;

            ResultSet rst = null;

            try{

                         //注冊(cè)數(shù)據(jù)庫(kù)驅(qū)動(dòng)程序

                Class.forName("oracle.jdbc.driver.OracleDriver");

                         //獲取數(shù)據(jù)庫(kù)連接

                con = DriverManager.getConnection("jdbc:oracle:thin:@10.60.203.80:1521:TestDB","123","123");

                         //獲取主鍵信息

                rst = con.getMetaData().getPrimaryKeys(null,null,"USER");

                         //打印主鍵信息

                if (!rst.isAfterLast()) {

                    rst.next();

                    System.out.println(rst.getString("TABLE_NAME") + " " +

                                      rst.getString("COLUMN_NAME"));

                }

            }

            catch (Exception e){

                System.out.println(e.getLocalizedMessage());

            }

            finally{

                try{

                                //關(guān)閉連接

                    if (rst != null)

                        rst.close();

                    if (con != null)

                        con.close();

                }

                catch (SQLException e){

                    throw e;

                }

            }

     

        }

    }

     

    上面的程序中,在獲取主鍵信息的時(shí)候,語(yǔ)句

    rst = con.getMetaData().getPrimaryKeys(null,null,"USER");

    用來(lái)獲取主鍵信息。關(guān)于該函數(shù)的詳細(xì)信息,請(qǐng)參閱JDK的文檔。這里要說(shuō)的是,在測(cè)試中發(fā)現(xiàn)第三個(gè)參數(shù)(數(shù)據(jù)庫(kù)表名)是大小寫敏感的,如果寫成user是查不到結(jié)果的。

     引自:http://m.tkk7.com/afrag/

    posted @ 2007-08-01 17:19 lubaolin 閱讀(4817) | 評(píng)論 (0)編輯 收藏

    工作中需要在程序中彈出窗口,并且聲音報(bào)警。查了資料,發(fā)現(xiàn)很多都是在網(wǎng)頁(yè)中用的,在應(yīng)用程序中應(yīng)用的很少,解決問(wèn)題之后,記錄下來(lái)。
    private void play(String path){
      try {
            FileInputStream sound_file=new FileInputStream(path);//獲得聲音文件
            try {
                  AudioStream AudioStream_sound=new AudioStream(sound_file);
                  AudioData sound_data = AudioStream_sound.getData();//轉(zhuǎn)化的wav文件這句會(huì)報(bào)錯(cuò)
                  ContinuousAudioDataStream sound_continue= new ContinuousAudioDataStream (sound_data);//循環(huán)播放
                  AudioPlayer.player.start(sound_continue);// Play audio.
                  //System.out.println("Play music success!");
                  AudioPlayer.player.stop(sound_continue);// Stop audio.
                 } catch (IOException e1) {
                   // TODO Auto-generated catch block
                   System.out.println("Play music fail!");
                   e1.printStackTrace();
                 }
               } catch (FileNotFoundException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
               }
           }
     
    注:1.這個(gè)程序段是應(yīng)用在應(yīng)用程序中,網(wǎng)頁(yè)中的聲音調(diào)用不適用。
        2.聲音片段可以為au格式和wav格式,但是注意的是,如果是別的格式如mp3格式轉(zhuǎn)化過(guò)來(lái)的,則在AudioData sound_data = AudioStream_sound.getData();系統(tǒng)會(huì)報(bào)錯(cuò)。
        3.調(diào)用的時(shí)候,盡量用線程,這樣可以避免沖突。

    引自:http://blog.sina.com.cn/u/53f7b6e401000a9w

    posted @ 2007-07-18 17:19 lubaolin 閱讀(1560) | 評(píng)論 (0)編輯 收藏

    <script language="Javascript"><!--
    function document.oncontextmenu(){event.returnValue=false;}//屏蔽鼠標(biāo)右鍵
    function window.onhelp(){return false} //屏蔽F1幫助
    function document.onkeydown()
    {
      if ((window.event.altKey)&&
          ((window.event.keyCode==37)||   //屏蔽 Alt+ 方向鍵 ←
           (window.event.keyCode==39)))   //屏蔽 Alt+ 方向鍵 →
      {
         alert("不準(zhǔn)你使用ALT+方向鍵前進(jìn)或后退網(wǎng)頁(yè)!");
         event.returnValue=false;
      }
         /* 注:這還不是真正地屏蔽 Alt+ 方向鍵,
         因?yàn)?Alt+ 方向鍵彈出警告框時(shí),按住 Alt 鍵不放,
         用鼠標(biāo)點(diǎn)掉警告框,這種屏蔽方法就失效了。以后若
         有哪位高手有真正屏蔽 Alt 鍵的方法,請(qǐng)告知。*/

      if ((event.keyCode==8)  ||                 //屏蔽退格刪除鍵
          (event.keyCode==116)||                 //屏蔽 F5 刷新鍵
          (event.ctrlKey && event.keyCode==82)){ //Ctrl + R
         event.keyCode=0;
         event.returnValue=false;
         }
      if (event.keyCode==122){event.keyCode=0;event.returnValue=false;}  //屏蔽F11
      if (event.ctrlKey && event.keyCode==78) event.returnValue=false;   //屏蔽 Ctrl+n
      if (event.shiftKey && event.keyCode==121)event.returnValue=false;  //屏蔽 shift+F10
      if (window.event.srcElement.tagName == "A" && window.event.shiftKey) 
          window.event.returnValue = false;             //屏蔽 shift 加鼠標(biāo)左鍵新開(kāi)一網(wǎng)頁(yè)
      if ((window.event.altKey)&&(window.event.keyCode==115))             //屏蔽Alt+F4
      {
          window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
          return false;
      }
    }
    </script>

    posted @ 2007-07-12 10:42 lubaolin 閱讀(8124) | 評(píng)論 (4)編輯 收藏

    <script>

    if (document.layers){

    var larg=screen.availWidth-10;

    var altez=screen.availHeight-20;}

    else{

    var larg=screen.availWidth+8;

    var altez=screen.availHeight+7;}

    self.resizeTo(larg,altez);

    self.moveTo(-4,-4);

    </script>


    <script>

    function sss(){

    window.moveTo(-4,-4)

    window.resizeTo(screen.availWidth+9,screen.availHeight+9)

    }

    </script>

    <a href="#" onclick="sss()">最大化</a>

    posted @ 2007-07-12 10:41 lubaolin 閱讀(1663) | 評(píng)論 (1)編輯 收藏

    1:連接池的必知概念
       
    首先,我們還是老套的講講連接池的基本概念,概念理解清楚了,我們也知道后面是怎么回事了。
    以前我們程序連接數(shù)據(jù)庫(kù)的時(shí)候,每一次連接數(shù)據(jù)庫(kù)都要一個(gè)連接,用完后再釋放。如果頻繁的數(shù)據(jù)庫(kù)操作,就會(huì)導(dǎo)致性能很低。連接池的出現(xiàn),為開(kāi)發(fā)過(guò)程提供了一個(gè)很好的管理平臺(tái)。當(dāng)程序中需要建立數(shù)據(jù)庫(kù)連接時(shí),只須從內(nèi)存中取一個(gè)來(lái)用而不用新建。同樣,使用完畢后,只需放回內(nèi)存即可。而連接的建立、斷開(kāi)都有連接池自身來(lái)管理。同時(shí),我們還可以通過(guò)設(shè)置連接池的參數(shù)來(lái)控制連接池中的連接數(shù)、每個(gè)連接的最大使用次數(shù)等等。通過(guò)使用連接池,將大大提高程序效率,同時(shí),我們可以通過(guò)其自身的管理機(jī)制來(lái)監(jiān)視數(shù)據(jù)庫(kù)連接的數(shù)量、使用情況等。

    Hibernate的出現(xiàn)把連接池的使用引入了一個(gè)新的利用方式,讓你充分享受配置化給開(kāi)發(fā)帶來(lái)的便利。


        2
    Hibernate連接池的配置
     
        
        
    在這里筆者簡(jiǎn)單介紹一下Hibernate配置連接池的方式:

       
    方式1:使用Hibernate自帶的連接池。

       
    方式2:使用配置文件指定的數(shù)據(jù)庫(kù)連接池。

       
    方式3:從容器中獲取得到連接池(如:Tomcat


        Hibernate
    無(wú)論采用哪種方式獲取連接池的連接,它對(duì)Java程序來(lái)說(shuō)是獨(dú)立的。Hibernate對(duì)其采用了配置化處理,也就是當(dāng)想改變獲取數(shù)據(jù)庫(kù)連接的方式時(shí),只要修改Hibernate的配置文件就可以了,看看多方便,就是這么簡(jiǎn)單,這足以讓你愛(ài)死Hibernate了。哈哈,讓我們正式來(lái)看看,Hibernate究竟是怎么做的!

       
    注意:Hibernate配置文件有兩鐘格式一個(gè)是XML格式,一種是properties格式。本文采用的是主流的XML格式來(lái)分析!
     

       
    1)使用Hibernate自帶的連接池

        Hibernate
    自帶的連接池性能不高,缺乏響應(yīng)大批量請(qǐng)求以及容錯(cuò)能力,甚至還有BUG,在項(xiàng)目運(yùn)用中不值得推薦。雖然缺點(diǎn)一羅筐,可也是Hibernate獲取連接池的一種方式,在這里筆者僅給出配置方法,以供參考,如下代碼所示:

    ………..

    <hibernate-configuration>

    <session-factory >

    <!--JDBC驅(qū)動(dòng)程序-->

    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

    <!-- 連接數(shù)據(jù)庫(kù)的URL-->

    <property name="connection.url">

    jdbc:mysql://localhost:3306/feifei

    </property>

    <!--連接的登錄名-->

    <property name="connection.username">root</property>

    <!--登錄密碼-->

    <property name="connection.password"></property>

    <!--是否將運(yùn)行期生成的SQL輸出到日志以供調(diào)試-->

    <property name="show_sql">true</property>

    <!--指定連接的語(yǔ)言-->

    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

    <!--映射資源-->

    <mapping resource="/xx/xx.hbm.xml" />

    </session-factory>

    </hibernate-configuration>

    (2)使用配置文件指定的連接池
       
       
    筆者在這里推薦當(dāng)今穩(wěn)定而且主流的數(shù)據(jù)源,就是Hibernate支持的第三方連接池產(chǎn)品:C3P0Proxool。隨著文章的深入,你會(huì)發(fā)現(xiàn)他們配置方法也有很大的不同。

       
    先來(lái)介紹連接池C3P0配置,在寫入配置文件之前,用戶必須將c3p0-0.8.4.5.jar這個(gè)包放入classpath當(dāng)中,下面給出其核心配置項(xiàng)其他的配置項(xiàng)可參見(jiàn)上面的方式1。

    …………….

    <property name="c3p0.min_size">5</property> <!—在連接池中可用數(shù)據(jù)庫(kù)連接的最小數(shù)目-->

    <property name="c3p0.max_size">30</property> <!--在連接池中所有數(shù)據(jù)庫(kù)連接的最大數(shù)目-->

    <property name="c3p0.time_out">1800</property> <!—設(shè)定數(shù)據(jù)庫(kù)連接的超時(shí)時(shí)間-->

    <property name="c3p0.max_statement">50</property> <!—可以被緩存的PreparedStatement的最大數(shù)目-->

    …………….

    把上面的配置項(xiàng)添加到hibernate.cfg.xml中就可以了,看看是不是很簡(jiǎn)單?
       
    配置Proxool連接池,就沒(méi)有那么簡(jiǎn)單了,稍有不同!筆者原先,也按照配置C3P0連接池的方法去配置Proxool,然后一個(gè)大大的錯(cuò)誤向我招手了。無(wú)助之下,上網(wǎng)看看有沒(méi)有解決方法,就找到了一個(gè)筆者認(rèn)為不錯(cuò)的方法,推薦給大家。

    由于Proxool連接池只管理自己產(chǎn)生的連接,Hibernate又需要管理它,怎么辦呢?所以我的做法是單獨(dú)的建立一個(gè)XML文件來(lái)管理連接池,又在Hibernate里面設(shè)置相關(guān)的項(xiàng),讓HibernateProxool關(guān)聯(lián)起來(lái)。
     
       
    當(dāng)然首先你要把proxool-0.8.3.jar這個(gè)包放入classpath,再建立一個(gè)ProxoolConf.xml文件,這個(gè)文件便于管理建議和 hibernate.cfg.xml文件放在一起。內(nèi)容如下:

    <?xml version="1.0" encoding="utf-8"?>

    <!-- the proxool configuration can be embedded within your own application's.

    Anything outside the "proxool" tag is ignored. -->

    <something-else-entirely>

    <proxool>

    <alias>feifeiPool</alias> <!—連接池的別名可以隨便寫,但注意的是后面在hibernate部分要對(duì)應(yīng)-->

    <!--proxool只能管理由自己產(chǎn)生的連接-->

    <driver-url>jdbc:mysql://localhost:3306/feifei?useUnicode=true&characterEncoding=GBK</driver-url>

    <driver-class> com.mysql.jdbc.Driver </driver-class>

    <driver-properties>

    <property name="user" value="root"/>

    <property name="password" value=""/>

    </driver-properties>

    <!-- proxool自動(dòng)偵察各個(gè)連接狀態(tài)的時(shí)間間隔(毫秒),偵察到空閑的連接就馬上回收,超時(shí)的銷毀-->

    <house-keeping-sleep-time>90000</house-keeping-sleep-time>

    <!--指因未有空閑連接可以分配而在隊(duì)列中等候的最大請(qǐng)求數(shù),超過(guò)這個(gè)請(qǐng)求數(shù)的用戶連接就不會(huì)被接受-->

    <maximum-new-connections>20</maximum-new-connections>

    <!-- 最少保持的空閑連接數(shù)-->

    <prototype-count>5</prototype-count>

    <!-- 允許最大連接數(shù),超過(guò)了這個(gè)連接,再有請(qǐng)求時(shí),就排在隊(duì)列中等候,最大的等待請(qǐng)求數(shù)由maximum-new-connections決定-->

    <maximum-connection-count>100</maximum-connection-count>

    <!-- 最小連接數(shù)-->

    <minimum-connection-count>10</minimum-connection-count>

    </proxool>

    </something-else-entirely>

     

    然后需要在hibernate.cfg.xml中作配置,參考如下:

    …………

    <property name="proxool.pool_alias">feifeiPool</property> <!—這個(gè)名字要和上面XML文件中的別名要對(duì)應(yīng)啊-->

    <property name="proxool.xml">ProxoolConf.xml</property> <!—這個(gè)你剛才上面建立的XML文件的名字-->

    <property name="connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>

    <!—定義Hibernate-->

    …………

    C3P0連接池不同,Proxool連接池配置有兩個(gè)步驟,請(qǐng)大家注意!至于c3p0,有評(píng)論說(shuō)它的算法不是最優(yōu)的,proxool不少行家推薦使用,而且暫時(shí)來(lái)說(shuō),是負(fù)面評(píng)價(jià)是最少的一個(gè)。性能是上,筆者也推薦使用這個(gè)。
          (3)
    從容器中獲取得到連接池(如:Tomcat

       
    筆者以我們大家常用的Tomcat為例子來(lái)描述,Hibernate想要從Tomcat中獲取數(shù)據(jù)源,需要對(duì)Tomcat容器與Hibernate分別進(jìn)行配置。

        <1>
    在容器中配置數(shù)據(jù)源

       
    配置容器的數(shù)據(jù)源,這里不多講,屬于服務(wù)器的配置范疇。假定已經(jīng)配好了一個(gè)JNDI名為“jdbc/feifei”的數(shù)據(jù)源。

        <2>
    hibernate.cfg.xml中指定使用這個(gè)名為“jdbc/feifei”
    JNDI
        <property name=”hibernate.connection.datasource”>java:/comp/env/jdbc/feifei </property>
        <!—
    指定這個(gè)JNDI名字就可以了,而且必須是完整的,一定要注意哦!
    -->
        
    本文的連接池方案分析就到此為止了。看完了,是不是很有想法?Hibernate配置連接池方面有這么多的方法提供給我們來(lái)選,選擇的余地多了,發(fā)揮的空間也大了。

        3
    :編后語(yǔ)

       
    連接池為我們開(kāi)發(fā)帶來(lái)了極大的便利,它為我們開(kāi)發(fā)者承擔(dān)了數(shù)據(jù)庫(kù)連接管理的壓力,讓我們從煩瑣的數(shù)據(jù)庫(kù)事務(wù)中解脫出來(lái),專心研究業(yè)務(wù)邏輯實(shí)現(xiàn)業(yè)務(wù),是我們的一大福音。

    本文分析的Hibernate連接池配置方案,為讀者提供了多種選擇。建議讀者也根據(jù)自己的實(shí)際情況來(lái)選取方案。文中肯定還有很多紕漏之處,還望大家斧正。講的不足的地方,以后有機(jī)會(huì)定當(dāng)補(bǔ)全!

     

     

    1Hibernate默認(rèn)連接池
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    <session-factory >
    <!?JDBC
    驅(qū)動(dòng)程序-->
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

     

    <!-- 連接數(shù)據(jù)庫(kù)的URL-->
    <property name="connection.url"> 
    jdbc:mysql://localhost:3306/schoolproject
    </property>
    <property name="connection.useUnicode">true</property>
    <property name="connection.characterEncoding">UTF-8</property>

    <!--
    連接的登錄名
    -->
    <property name="connection.username">root</property>

    <!?
    登錄密碼
    -->
    <property name="connection.password"></property>

    <!--
    是否將運(yùn)行期生成的SQL輸出到日志以供調(diào)試
    -->
    <property name="show_sql">true</property>

    <!--
    指定連接的語(yǔ)言
    -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

    <!--
    映射Student這個(gè)資源
    -->
    <mapping resource="com/wqbi/model/pojo/student.hbm.xml" />

    </session-factory> 
    </hibernate-configuration>


    2
    C3P0連接配置
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

    <hibernate-configuration>
    <session-factory >
    <!?JDBC
    驅(qū)動(dòng)程序-->
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

    <!-- 
    連接數(shù)據(jù)庫(kù)的
    URL-->
    <property name="connection.url"> 
    jdbc:mysql://localhost:3306/schoolproject
    </property>

    <property name="connection.useUnicode">true</property>
    <property name="connection.characterEncoding">UTF-8</property>

    <!--
    連接的登錄名
    -->
    <property name="connection.username">root</property>

    <!--
    登錄密碼
    -->
    <property name="connection.password"></property>

    <!-- C3P0
    連接池設(shè)定
    -->

    <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider
    </property>
    <property name="hibernate.c3p0.max_size">20</property>
    <property name="hibernate.c3p0.min_size">5</property>
    <property name="hibernate.c3p0.timeout">120</property>
    <property name="hibernate.c3p0.max_statements">100</property>
    <property name="hibernate.c3p0.idle_test_period">120</property>
    <property name="hibernate.c3p0.acquire_increment">2</property>


    <!--
    是否將運(yùn)行期生成的SQL輸出到日志以供調(diào)試-->
    <property name="show_sql">true</property>
    <!--
    指定連接的語(yǔ)言
    -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

    <!--
    映射Student這個(gè)資源
    -->
    <mapping resource="com/wqbi/model/pojo/student.hbm.xml" />

    </session-factory> 
    </hibernate-configuration>

    3
    proxool連接池


    (1) 
    先寫proxool的配置文件,文件名:proxool.xml(一般放在與hibernate.cfg.xml文件在同一個(gè)目錄中)本例配置的是MYSQL數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù)的名字為schoolproject
    <?xml version="1.0" encoding="UTF-8"?> 
    <!-- the proxool configuration can be embedded within your own application's. 
    Anything outside the "proxool" tag is ignored. --> 
    <something-else-entirely>
    <proxool>
    <!--
    連接池的別名
    -->
    <alias>DBPool</alias>
    <!--proxool
    只能管理由自己產(chǎn)生的連接
    -->

    <driver-url>
    jdbc:mysql://localhost:3306/schoolproject?useUnicode=true&characterEncoding=UTF8
    </driver-url>

    <!?JDBC驅(qū)動(dòng)程序-->
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <driver-properties>
    <property name="user" value="root"/>
    <property name="password" value=""/>
    </driver-properties> 

    <!-- proxool
    自動(dòng)偵察各個(gè)連接狀態(tài)的時(shí)間間隔(毫秒),偵察到空閑的連接就馬上回

    ,超時(shí)的銷毀--> 
    <house-keeping-sleep-time>90000</house-keeping-sleep-time>

    <!-- 
    指因未有空閑連接可以分配而在隊(duì)列中等候的最大請(qǐng)求數(shù),超過(guò)這個(gè)請(qǐng)求數(shù)的

    用戶連接就不會(huì)被接受--> 
    <maximum-new-connections>20</maximum-new-connections>
    <!-- 
    最少保持的空閑連接數(shù)
    --> 
    <prototype-count>5</prototype-count>

    <!-- 
    允許最大連接數(shù),超過(guò)了這個(gè)連接,再有請(qǐng)求時(shí),就排在隊(duì)列中等候,最大的

    等待請(qǐng)求數(shù)由maximum-new-connections決定--> 
    <maximum-connection-count>100</maximum-connection-count>

    <!-- 
    最小連接數(shù)
    -->
    <minimum-connection-count>10</minimum-connection-count>

    </proxool> 
    </something-else-entirely>

    (2)
    配置hibernate.cfg.xml文件

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    <session-factory >
    <property name="hibernate.connection.provider_class">
    org.hibernate.connection.ProxoolConnectionProvider
    </property>
    <property name="hibernate.proxool.pool_alias">DBPool</property>
    <property name="hibernate.proxool.xml">proxoolconf.xml</property>

    <!--
    是否將運(yùn)行期生成的SQL輸出到日志以供調(diào)試-->
    <property name="show_sql">true</property>
    <!--
    指定連接的語(yǔ)言
    -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

    <!--
    映射Student這個(gè)資源
    -->
    <mapping resource="com/wqbi/model/pojo/student.hbm.xml" />

    </session-factory> 
    </hibernate-configuration>
    (1) hibernate.connection.provider_class
    定義Hibernate的連接加載類,這里Proxool連接池是用這個(gè),不同的連接池有不同的加載類,可以查閱Hibernate文檔獲取相關(guān)信息


    (2) hibernate.proxool.pool_alias
    這里就是用我們上面提到的連接池的別名

    (3) hibernate.proxool.xml
    是向Hibernate聲明連接池的配置文件位置,可以用相對(duì)或絕對(duì)路徑,用相對(duì)路徑時(shí)要注意一定在要Path范圍內(nèi)!不然會(huì)拋出異常。

    (4) dialect
    是聲明SQL語(yǔ)句的方言

    (5) show_sql
    定義是否顯示Hibernate生成的SQL語(yǔ)言,一般在調(diào)試階段設(shè)為true,完成后再改成false,這樣有利于調(diào)試。

    (6) <mapping >
    資源文件映射

    4
    JNDI連接池,數(shù)據(jù)源已經(jīng)由應(yīng)用服務(wù)配置好(Web服務(wù)器),Hibernate需要做的只是通過(guò)JNDI名查找到此數(shù)據(jù)源。應(yīng)用服務(wù)器將連接池對(duì)外顯示為JNDI綁定數(shù)據(jù)源,它是javax.jdbc.Datasource類的一個(gè)實(shí)例。只要配置一個(gè)Hibernate文件,如:
    hibernate.connection.datasource=java:/comp/env/jdbc/schoolproject //JNDI

    hibernate.transaction.factory_class = org.hibernate.transaction.JTATransactionFactory
    hibernate.transaction.manager_loopup_class =
    org.hibernate.transaction.JBossTransactionManagerLookup
    hibernate.dialect=org.hibernate.dialect.MySQLDialect

    轉(zhuǎn)自:http://www.cublog.cn/u/27479/showart_218912.html

    posted @ 2007-05-11 16:33 lubaolin 閱讀(7665) | 評(píng)論 (6)編輯 收藏

    美特斯邦威:不加尋常班               
    特步: 加班, 死一般的感覺(jué)       
    百事:加班無(wú)極限   
    森馬:上什么公司,加什么班  
    腦白金:今年過(guò)節(jié)不加班,加班只加節(jié)假日   
    匯仁腎寶:他加我也加   
    李寧:加班, 一切皆有可能   
    旺旺: 你加,我加,大家加,加加  
    農(nóng)夫山泉:加了有點(diǎn)煩   
    好迪:大家加,才是真的加
    白加黑:白天加白班,不瞌睡;晚上加晚班,睡不著
    聯(lián)想:公司不加班,公司會(huì)怎么樣
    娃哈哈:媽媽~~我也要加班!
    清嘴:你知道加班的味道嗎?
    安踏:我加班,我喜歡!
    NIKE:Just 加 it!
    鈣中鈣:現(xiàn)在的加班啊,它含金量高,加一天頂過(guò)去五天,實(shí)惠!你瞧我, 一口氣加了5天,不費(fèi)勁!

    posted @ 2007-04-16 11:19 lubaolin 閱讀(556) | 評(píng)論 (1)編輯 收藏

    bin>mysql -u root
    mysql> grant 權(quán)限1,權(quán)限2,…權(quán)限n on 數(shù)據(jù)庫(kù)名稱.表名稱 to 用戶名@用戶地址 identified by ‘連接口令’;

    權(quán)限1,權(quán)限2,…權(quán)限n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14個(gè)權(quán)限。
    當(dāng)權(quán)限1,權(quán)限2,…權(quán)限n被all privileges或者all代替,表示賦予用戶全部權(quán)限。
    當(dāng)數(shù)據(jù)庫(kù)名稱.表名稱被*.*代替,表示賦予用戶操作服務(wù)器上所有數(shù)據(jù)庫(kù)所有表的權(quán)限。
    用戶地址可以是localhost,也可以是ip地址、機(jī)器名字、域名。也可以用’%'表示從任何地址連接。
    ‘連接口令’不能為空,否則創(chuàng)建失敗。



    例如:
    mysql>grant select,insert,update,delete,create,drop on vtdc.employee to joe@10.163.225.87 identified by ‘123′;
    給來(lái)自10.163.225.87的用戶joe分配可對(duì)數(shù)據(jù)庫(kù)vtdc的employee表進(jìn)行select,insert,update,delete,create,drop等操作的權(quán)限,并設(shè)定口令為123。

    mysql>grant all privileges on vtdc.* to joe@10.163.225.87 identified by ‘123′;
    給來(lái)自10.163.225.87的用戶joe分配可對(duì)數(shù)據(jù)庫(kù)vtdc所有表進(jìn)行所有操作的權(quán)限,并設(shè)定口令為123。

    mysql>grant all privileges on *.* to joe@10.163.225.87 identified by ‘123′;
    給來(lái)自10.163.225.87的用戶joe分配可對(duì)所有數(shù)據(jù)庫(kù)的所有表進(jìn)行所有操作的權(quán)限,并設(shè)定口令為123。

    mysql>grant all privileges on *.* to joe@localhost identified by ‘123′;
    給本機(jī)用戶joe分配可對(duì)所有數(shù)據(jù)庫(kù)的所有表進(jìn)行所有操作的權(quán)限,并設(shè)定口令為123。

    posted @ 2007-04-15 22:29 lubaolin 閱讀(1542) | 評(píng)論 (0)編輯 收藏

    1)swf從jsp讀數(shù)據(jù)
    a) 在flash中建一個(gè)動(dòng)態(tài)文本框,一個(gè)button;文本框名字叫str,button上寫


    on (release) {
    loadVariable("http://localhost:8080/demo/sentVar.jsp", "","get");
    }//url相對(duì),絕對(duì)路徑好像都可以


    b) 在sentVar.jsp中寫如下代碼:
    <%@ page contentType="text/html;charset=gb2312"%>
    <%
    String tmp="wowowo";
    out.println("&str="+tmp);//這里一定要寫成"&str="的形式,&一定不能少,str的名字要與你a中建的相同,“= ”號(hào)也不能少;
    %>
    c)測(cè)試。click button ...yeah~(failed?its none of my business) try again~~

    -------------------------------------------------------------------

    2)swf向jsp寫數(shù)據(jù)
    這個(gè)簡(jiǎn)單點(diǎn)。

    c建一input textfield,起個(gè)名字str吧。一個(gè)button,上面寫:
    on (release) {
    getURL("showrs.jsp", "","get");
    }


    b)showrs.jsp中寫:

    <%@ page contentType="text/html;charset=gb2312"%>
    <%
    String tem=request.getParameter("str");
    out.println("str="+tem);
    %>

    everything is ok~enjoy...

    引自:http://www.flashempire.net/showpost.php?p=892409

    posted @ 2007-03-28 09:08 lubaolin 閱讀(2878) | 評(píng)論 (2)編輯 收藏

    進(jìn)入頁(yè)面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
    退出頁(yè)面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
    x為效果持續(xù)的時(shí)間
    y的取值為1-23:

      0 矩形縮小
      1 矩形擴(kuò)大
      2 圓形縮小
      3 圓形擴(kuò)大
      4 下到上刷新
      5 上到下刷新
      6 左到右刷新
      7 右到左刷新
      8 豎百葉窗
      9 橫百葉窗
      10 錯(cuò)位橫百葉窗
      11 錯(cuò)位豎百葉窗
      12 點(diǎn)擴(kuò)散
      13 左右到中間刷新
      14 中間到左右刷新
      15 中間到上下
      16 上下到中間
      17 右下到左上
      18 右上到左下
      19 左上到右下
      20 左下到右上
      21 橫條
      22 豎條
      23 以上22種隨機(jī)選擇一種

    posted @ 2007-03-26 16:51 lubaolin 閱讀(1520) | 評(píng)論 (1)編輯 收藏

    我們經(jīng)常會(huì)用到db2 -tvf test.sql 來(lái)批量執(zhí)行test.sql文件中的所有語(yǔ)句,而tvf的具體含義是什么,請(qǐng)看一下介紹
    db2命令行參數(shù):以下列出當(dāng)前的db2命令行參數(shù)

    db2 => list command options

    命令行處理器選項(xiàng)設(shè)置

    后端進(jìn)程等待時(shí)間(秒) (DB2BQTIME) = 1
    連接至后端的重試次數(shù) (DB2BQTRY) = 60
    請(qǐng)求隊(duì)列等待時(shí)間(秒) (DB2RQTIME) = 5
    輸入隊(duì)列等待時(shí)間(秒) (DB2IQTIME) = 5
    命令選項(xiàng) (DB2OPTIONS) =

    選項(xiàng) 描述 當(dāng)前設(shè)置
    ------ ---------------------------------------- ---------------
    -a 顯示 SQLCA OFF
    -c 自動(dòng)落實(shí) OFF
    -e 顯示 SQLCODE/SQLSTATE OFF
    -f 讀取輸入文件 OFF
    -l 將命令記錄到歷史文件中 OFF
    -n 除去換行字符 OFF
    -o 顯示輸出 ON
    -p 顯示交互式輸入提示 ON
    -r 將輸出保存到報(bào)告文件 OFF
    -s 在命令出錯(cuò)時(shí)停止執(zhí)行 OFF
    -t 設(shè)置語(yǔ)句終止符 OFF
    -v 回送當(dāng)前命令 OFF
    -w 顯示 FETCH/SELECT 警告消息 ON
    -x 不打印列標(biāo)題 OFF
    -z 將所有輸出保存到輸出文件 OFF

    以下用來(lái)查看如何修改參數(shù):

    db2 => ? options
    db2 [option ...] [db2-command | sql-statement |
    [? [phrase | message | sqlstate | class-code]]]
    選項(xiàng):-a, -c, -e{c|s}, -finfile, -lhistfile, -n, -o, -p, -rreport, -s, -t,
    -td;, -v, -w, -x, -zoutputfile。

    選項(xiàng) 描述 缺省設(shè)置
    ------ ---------------------------------------- ---------------
    -a 顯示 SQLCA OFF
    -c 自動(dòng)落實(shí) ON
    -e 顯示 SQLCODE/SQLSTATE OFF
    -f 讀取輸入文件 OFF
    -l 將命令記錄到歷史文件中 OFF
    -n 除去換行字符 OFF
    -o 顯示輸出 ON
    -p 顯示 db2 交互式提示 ON
    -r 將輸出報(bào)告保存到文件 OFF
    -s 在命令出錯(cuò)時(shí)停止執(zhí)行 OFF
    -t 設(shè)置語(yǔ)句終止符 OFF
    -v 回送當(dāng)前命令 OFF
    -w 顯示 FETCH/SELECT 警告消息 ON
    -x 不打印列標(biāo)題 OFF
    -z 將所有輸出保存到輸出文件 OFF

    注意:
    使用 DB2OPTIONS 環(huán)境變量定制選項(xiàng)缺省值。
    緊跟選項(xiàng)字母后的減號(hào)(-)使該選項(xiàng)關(guān)閉。
    使用 UPDATE COMMAND OPTIONS 更改選項(xiàng)設(shè)置(以交互式或
    文件輸入方式)。

    如何修改,請(qǐng)輸入:

    db2 => ? update command options

    比如修改為不自動(dòng)提交:

    update command options using c off


    在db2命令行提示符下,輸入?,就可以查看所有的CLP命令

    輸入: ? command (clp命令名) 比如: ? connect

    db2 => ? connect
    CONNECT [USER username [{USING password
    [NEW new-password CONFIRM confirm-password] |
    CHANGE PASSWORD}]]

    CONNECT RESET

    CONNECT TO database-alias
    [IN {SHARE MODE | EXCLUSIVE MODE [ON SINGLE DBPARTITIONNUM]}]
    [USER username [{USING password
    [NEW new-password CONFIRM confirm-password] |
    CHANGE PASSWORD}]]

    方括號(hào)中的參數(shù)是可選參數(shù),尖括號(hào)中的內(nèi)容表示變量。

    以下是常用的:

    實(shí)例

    db2start 啟動(dòng)數(shù)據(jù)庫(kù)管理器實(shí)例。
    db2stop 停止數(shù)據(jù)庫(kù)管理器實(shí)例。
    get dbm cfg 返回?cái)?shù)據(jù)庫(kù)管理器配置設(shè)置。
    get dbm cfg show detail 顯示數(shù)據(jù)庫(kù)管理器參數(shù)的當(dāng)前值和延遲值(從 V8 起)。
    1update dbm cfg using  將數(shù)據(jù)庫(kù)管理器配置參數(shù) 更新為值 。 
    get instance 返回 DB2INSTANCE 環(huán)境變量的值。
    list active databases 列出活動(dòng)的數(shù)據(jù)庫(kù)和連接數(shù)。
    list application [show detail] 返回關(guān)于當(dāng)前連接的應(yīng)用程序的信息。
    force application (h1 [,h2,..,hn]) 根據(jù)句柄號(hào)與特定應(yīng)用程序斷開(kāi)連接。
    force application all 斷開(kāi)所有應(yīng)用程序與數(shù)據(jù)庫(kù)的連接。
    attach to user using  以用戶 通過(guò)使用密碼 與標(biāo)識(shí)為 的遠(yuǎn)程實(shí)例連接。

     

    數(shù)據(jù)庫(kù)

    create database  創(chuàng)建名為 的數(shù)據(jù)庫(kù)。
    activate database  顯式地激活數(shù)據(jù)庫(kù)。
    deactivate database  顯式地使數(shù)據(jù)庫(kù)失效。
    connect to [ [user ] using ]  根據(jù)需要,顯式地以用戶 和密碼 與數(shù)據(jù)庫(kù) 連接。
    1update dbm cfg using  將數(shù)據(jù)庫(kù)管理器配置參數(shù) 更新為值 。 
    connect reset 斷開(kāi)與當(dāng)前數(shù)據(jù)庫(kù)的連接。
    get db cfg show detail 顯示數(shù)據(jù)庫(kù)配置參數(shù)的當(dāng)前值和延遲值(僅適用于 V8)。
    get db cfg for  返回?cái)?shù)據(jù)庫(kù) 的數(shù)據(jù)庫(kù)配置設(shè)置。
    update db cfg for using  將數(shù)據(jù)庫(kù) 的數(shù)據(jù)庫(kù)配置參數(shù) 更新為值 。 
    list tables[for {user | all | system | schema }][show detail] 列出數(shù)據(jù)庫(kù)中的表。如果沒(méi)有指定任何參數(shù),則缺省情況是列出當(dāng)前用戶的表。
    describe table  顯示一個(gè)表或視圖的列信息。
    list tablespaces [show detail] 顯示表空間的標(biāo)識(shí)、名稱、類型、內(nèi)容和狀態(tài)。
    list tablespace containers for [show detail] 顯示用 指定的表空間的容器信息。
    quiesce tablespaces for table reset 將表空間的狀態(tài)復(fù)位成正常(normal)。

     

    連接性

    catalog [admin] node … 為協(xié)議 在節(jié)點(diǎn)目錄中創(chuàng)建一項(xiàng)。
    list [admin] node directory 返回節(jié)點(diǎn)目錄的內(nèi)容。
    catalog database … 為數(shù)據(jù)庫(kù) 在數(shù)據(jù)庫(kù)目錄中創(chuàng)建一項(xiàng)。
    list database directory [on ] 返回?cái)?shù)據(jù)庫(kù)目錄的內(nèi)容。

     

    性能

    get monitor switches 返回會(huì)話監(jiān)控開(kāi)關(guān)的狀態(tài)。
    update monitor switches using  為 設(shè)置會(huì)話監(jiān)控開(kāi)關(guān)的狀態(tài)。
    reset monitor all 復(fù)位性能監(jiān)控程序值。
    get snapshot for dbm 返回實(shí)例級(jí)別的性能信息。
    get snapshot for all on  為數(shù)據(jù)庫(kù) 在數(shù)據(jù)庫(kù)級(jí)別返回所有性能信息。
    get snapshot for dynamic sql on  返回動(dòng)態(tài) SQL 高速緩存的內(nèi)容。
    runstats on table . 收集表 的統(tǒng)計(jì)信息。表名必須是用 全限定的。
    reorgchk on table all 確定是否需要對(duì)表進(jìn)行重組。這對(duì)于對(duì)所有表自動(dòng)執(zhí)行 runstats 很有用。
    reorg table  通過(guò)重構(gòu)行來(lái)消除“碎片”數(shù)據(jù)并壓縮信息,對(duì)表進(jìn)行重組。

     

    管理

    export 將數(shù)據(jù)庫(kù)數(shù)據(jù)抽取到一個(gè)平面文件中。
    import 通過(guò)使用 IMPORT 實(shí)用程序,將數(shù)據(jù)導(dǎo)入到數(shù)據(jù)庫(kù)。
    load query table [to local-message-file][nosummary | summaryonly] [showdelta]  返回 LOAD 實(shí)用程序的進(jìn)度。
    backup database [to ] 執(zhí)行數(shù)據(jù)庫(kù)備份。
    restore database [from ] 執(zhí)行數(shù)據(jù)庫(kù)恢復(fù)。
    get health snapshot for dbm 返回實(shí)例的正??煺招畔ⅲ▋H適用于 V8)。
    get health snapshot for all on  返回?cái)?shù)據(jù)庫(kù) 的所有正??煺眨▋H適用于 V8)。

     

    管理服務(wù)器

    get admin cfg 返回管理服務(wù)器的配置設(shè)置。
    update admin cfg using  將管理服務(wù)器配置參數(shù) 更新為值 。

    posted @ 2007-03-16 12:58 lubaolin 閱讀(912) | 評(píng)論 (0)編輯 收藏

    1、查看表空間的名稱及大小
    select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
    from dba_tablespaces t, dba_data_files d
    where t.tablespace_name = d.tablespace_name
    group by t.tablespace_name;

    2、查看表空間物理文件的名稱及大小
    select tablespace_name, file_id, file_name,
    round(bytes/(1024*1024),0) total_space
    from dba_data_files
    order by tablespace_name;

    3、查看回滾段名稱及大小
    select segment_name, tablespace_name, r.status,
    (initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent,
    max_extents, v.curext CurExtent
    From dba_rollback_segs r, v$rollstat v
    Where r.segment_id = v.usn(+)
    order by segment_name ;

    4、查看控制文件
    select name from v$controlfile;

    5、查看日志文件
    select member from v$logfile;

    6、查看表空間的使用情況
    select sum(bytes)/(1024*1024) as free_space,tablespace_name
    from dba_free_space
    group by tablespace_name;

    SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,
    (B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"
    FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
    WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;

    7、查看數(shù)據(jù)庫(kù)庫(kù)對(duì)象
    select owner, object_type, status, count(*) count# from all_objects group by owner, object_type, status;

    8、查看數(shù)據(jù)庫(kù)的版本 
    Select version FROM Product_component_version
    Where SUBSTR(PRODUCT,1,6)='Oracle';

    9、查看數(shù)據(jù)庫(kù)的創(chuàng)建日期和歸檔方式
    Select Created, Log_Mode, Log_Mode From V$Database;

    10、捕捉運(yùn)行很久的SQL
    column username format a12
    column opname format a16
    column progress format a8

    select username,sid,opname,
    round(sofar*100 / totalwork,0) || '%' as progress,
    time_remaining,sql_text
    from v$session_longops , v$sql
    where time_remaining <> 0
    and sql_address = address
    and sql_hash_value = hash_value
    /

    11、查看數(shù)據(jù)表的參數(shù)信息
    SELECT partition_name, high_value, high_value_length, tablespace_name,
    pct_free, pct_used, ini_trans, max_trans, initial_extent,
    next_extent, min_extent, max_extent, pct_increase, FREELISTS,
    freelist_groups, LOGGING, BUFFER_POOL, num_rows, blocks,
    empty_blocks, avg_space, chain_cnt, avg_row_len, sample_size,
    last_analyzed
    FROM dba_tab_partitions
    --WHERE table_name = :tname AND table_owner = :towner
    ORDER BY partition_position

    12、查看還沒(méi)提交的事務(wù)
    select * from v$locked_object;
    select * from v$transaction;

    13、查找object為哪些進(jìn)程所用
    select
    p.spid,
    s.sid,
    s.serial# serial_num,
    s.username user_name,
    a.type object_type,
    s.osuser os_user_name,
    a.owner,
    a.object object_name,
    decode(sign(48 - command),
    1,
    to_char(command), 'Action Code #' || to_char(command) ) action,
    p.program oracle_process,
    s.terminal terminal,
    s.program program,
    s.status session_status
    from v$session s, v$access a, v$process p
    where s.paddr = p.addr and
    s.type = 'USER' and
    a.sid = s.sid and
    a.object='SUBSCRIBER_ATTR'
    order by s.username, s.osuser

    14、回滾段查看
    select rownum, sys.dba_rollback_segs.segment_name Name, v$rollstat.extents
    Extents, v$rollstat.rssize Size_in_Bytes, v$rollstat.xacts XActs,
    v$rollstat.gets Gets, v$rollstat.waits Waits, v$rollstat.writes Writes,
    sys.dba_rollback_segs.status status from v$rollstat, sys.dba_rollback_segs,
    v$rollname where v$rollname.name(+) = sys.dba_rollback_segs.segment_name and
    v$rollstat.usn (+) = v$rollname.usn order by rownum

    15、耗資源的進(jìn)程(top session)
    select s.schemaname schema_name, decode(sign(48 - command), 1,
    to_char(command), 'Action Code #' || to_char(command) ) action, status
    session_status, s.osuser os_user_name, s.sid, p.spid , s.serial# serial_num,
    nvl(s.username, '[Oracle process]') user_name, s.terminal terminal,
    s.program program, st.value criteria_value from v$sesstat st, v$session s , v$process p
    where st.sid = s.sid and st.statistic# = to_number('38') and ('ALL' = 'ALL'
    or s.status = 'ALL') and p.addr = s.paddr order by st.value desc, p.spid asc, s.username asc, s.osuser asc

    16、查看鎖(lock)情況
    select /*+ RULE */ ls.osuser os_user_name, ls.username user_name,
    decode(ls.type, 'RW', 'Row wait enqueue lock', 'TM', 'DML enqueue lock', 'TX',
    'Transaction enqueue lock', 'UL', 'User supplied lock') lock_type,
    o.object_name object, decode(ls.lmode, 1, null, 2, 'Row Share', 3,
    'Row Exclusive', 4, 'Share', 5, 'Share Row Exclusive', 6, 'Exclusive', null)
    lock_mode, o.owner, ls.sid, ls.serial# serial_num, ls.id1, ls.id2
    from sys.dba_objects o, ( select s.osuser, s.username, l.type,
    l.lmode, s.sid, s.serial#, l.id1, l.id2 from v$session s,
    v$lock l where s.sid = l.sid ) ls where o.object_id = ls.id1 and o.owner
    <> 'SYS' order by o.owner, o.object_name

    17、查看等待(wait)情況
    SELECT v$waitstat.class, v$waitstat.count count, SUM(v$sysstat.value) sum_value
    FROM v$waitstat, v$sysstat WHERE v$sysstat.name IN ('db block gets',
    'consistent gets') group by v$waitstat.class, v$waitstat.count

    18、查看sga情況
    SELECT NAME, BYTES FROM SYS.V_$SGASTAT ORDER BY NAME ASC

    19、查看catched object
    SELECT owner, name, db_link, namespace,
    type, sharable_mem, loads, executions,
    locks, pins, kept FROM v$db_object_cache

    20、查看V$SQLAREA
    SELECT SQL_TEXT, SHARABLE_MEM, PERSISTENT_MEM, RUNTIME_MEM, SORTS,
    VERSION_COUNT, LOADED_VERSIONS, OPEN_VERSIONS, USERS_OPENING, EXECUTIONS,
    USERS_EXECUTING, LOADS, FIRST_LOAD_TIME, INVALIDATIONS, PARSE_CALLS, DISK_READS,
    BUFFER_GETS, ROWS_PROCESSED FROM V$SQLAREA

    21、查看object分類數(shù)量
    select decode (o.type#,1,'INDEX' , 2,'TABLE' , 3 , 'CLUSTER' , 4, 'VIEW' , 5 ,
    'SYNONYM' , 6 , 'SEQUENCE' , 'OTHER' ) object_type , count(*) quantity from
    sys.obj$ o where o.type# > 1 group by decode (o.type#,1,'INDEX' , 2,'TABLE' , 3
    , 'CLUSTER' , 4, 'VIEW' , 5 , 'SYNONYM' , 6 , 'SEQUENCE' , 'OTHER' ) union select
    'COLUMN' , count(*) from sys.col$ union select 'DB LINK' , count(*) from

    22、按用戶查看object種類
    select u.name schema, sum(decode(o.type#, 1, 1, NULL)) indexes,
    sum(decode(o.type#, 2, 1, NULL)) tables, sum(decode(o.type#, 3, 1, NULL))
    clusters, sum(decode(o.type#, 4, 1, NULL)) views, sum(decode(o.type#, 5, 1,
    NULL)) synonyms, sum(decode(o.type#, 6, 1, NULL)) sequences,
    sum(decode(o.type#, 1, NULL, 2, NULL, 3, NULL, 4, NULL, 5, NULL, 6, NULL, 1))
    others from sys.obj$ o, sys.user$ u where o.type# >= 1 and u.user# =
    o.owner# and u.name <> 'PUBLIC' group by u.name order by
    sys.link$ union select 'CONSTRAINT' , count(*) from sys.con$

    23、有關(guān)connection的相關(guān)信息
    1)查看有哪些用戶連接
    select s.osuser os_user_name, decode(sign(48 - command), 1, to_char(command),
    'Action Code #' || to_char(command) ) action, p.program oracle_process,
    status session_status, s.terminal terminal, s.program program,
    s.username user_name, s.fixed_table_sequence activity_meter, '' query,
    0 memory, 0 max_memory, 0 cpu_usage, s.sid, s.serial# serial_num
    from v$session s, v$process p where s.paddr=p.addr and s.type = 'USER'
    order by s.username, s.osuser
    2)根據(jù)v.sid查看對(duì)應(yīng)連接的資源占用等情況
    select n.name,
    v.value,
    n.class,
    n.statistic#
    from v$statname n,
    v$sesstat v
    where v.sid = 71 and
    v.statistic# = n.statistic#
    order by n.class, n.statistic#
    3)根據(jù)sid查看對(duì)應(yīng)連接正在運(yùn)行的sql
    select /*+ PUSH_SUBQ */
    command_type,
    sql_text,
    sharable_mem,
    persistent_mem,
    runtime_mem,
    sorts,
    version_count,
    loaded_versions,
    open_versions,
    users_opening,
    executions,
    users_executing,
    loads,
    first_load_time,
    invalidations,
    parse_calls,
    disk_reads,
    buffer_gets,
    rows_processed,
    sysdate start_time,
    sysdate finish_time,
    '>' || address sql_address,
    'N' status
    from v$sqlarea
    where address = (select sql_address from v$session where sid = 71)

    24、查詢表空間使用情況select a.tablespace_name "表空間名稱",
    100-round((nvl(b.bytes_free,0)/a.bytes_alloc)*100,2) "占用率(%)",
    round(a.bytes_alloc/1024/1024,2) "容量(M)",
    round(nvl(b.bytes_free,0)/1024/1024,2) "空閑(M)",
    round((a.bytes_alloc-nvl(b.bytes_free,0))/1024/1024,2) "使用(M)",
    Largest "最大擴(kuò)展段(M)",
    to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') "采樣時(shí)間"
    from (select f.tablespace_name,
    sum(f.bytes) bytes_alloc,
    sum(decode(f.autoextensible,'YES',f.maxbytes,'NO',f.bytes)) maxbytes
    from dba_data_files f
    group by tablespace_name) a,
    (select f.tablespace_name,
    sum(f.bytes) bytes_free
    from dba_free_space f
    group by tablespace_name) b,
    (select round(max(ff.length)*16/1024,2) Largest,
    ts.name tablespace_name
    from sys.fet$ ff, sys.file$ tf,sys.ts$ ts
    where ts.ts#=ff.ts# and ff.file#=tf.relfile# and ts.ts#=tf.ts#
    group by ts.name, tf.blocks) c
    where a.tablespace_name = b.tablespace_name and a.tablespace_name = c.tablespace_name

    25、 查詢表空間的碎片程度
    select tablespace_name,count(tablespace_name) from dba_free_space group by tablespace_name
    having count(tablespace_name)>10;

    alter tablespace name coalesce;
    alter table name deallocate unused;

    create or replace view ts_blocks_v as
    select tablespace_name,block_id,bytes,blocks,'free space' segment_name from dba_free_space
    union all
    select tablespace_name,block_id,bytes,blocks,segment_name from dba_extents;

    select * from ts_blocks_v;

    select tablespace_name,sum(bytes),max(bytes),count(block_id) from dba_free_space
    group by tablespace_name;

    posted @ 2007-03-09 14:53 lubaolin 閱讀(372) | 評(píng)論 (0)編輯 收藏

    1.字符串函數(shù)
    長(zhǎng)度與分析用
    datalength(Char_expr)返回字符串包含字符數(shù),但不包含后面的空格
    substring(expression,start,length)不多說(shuō)了,取子串
    right(char_expr,int_expr)返回字符串右邊int_expr個(gè)字符

    字符操作類
    upper(char_expr)轉(zhuǎn)為大寫
    lower(char_expr)轉(zhuǎn)為小寫
    space(int_expr)生成int_expr個(gè)空格
    replicate(char_expr,int_expr)復(fù)制字符串int_expr次
    reverse(char_expr)反轉(zhuǎn)字符串
    stuff(char_expr1,start,length,char_expr2)將字符串char_expr1中的從start開(kāi)始的length個(gè)字符用char_expr2代替
    ltrim(char_expr)rtrim(char_expr)取掉空格
    ascii(char)char(ascii)兩函數(shù)對(duì)應(yīng),取ascii碼,根據(jù)ascii嗎取字符

    字符串查找
    charindex(char_expr,expression)返回char_expr的起始位置
    patindex("pattern",expression)返回指定模式的起始位置,否則為0

    2.數(shù)學(xué)函數(shù)
    abs(numeric_expr)求絕對(duì)值
    ceiling(numeric_expr)取大于等于指定值的最小整數(shù)
    exp(float_expr)取指數(shù)
    floor(numeric_expr)小于等于指定值得最大整數(shù)
    pi()3.1415926.........
    power(numeric_expr,power)返回power次方
    rand([int_expr])隨機(jī)數(shù)產(chǎn)生器
    round(numeric_expr,int_expr)安int_expr規(guī)定的精度四舍五入
    sign(int_expr)根據(jù)正數(shù),0,負(fù)數(shù),,返回 1,0,-1
    sqrt(float_expr)平方根

    3.日期函數(shù)
    getdate()返回日期
    datename(datepart,date_expr)返回名稱如June
    datepart(datepart,date_expr)取日期一部份
    datediff(datepart,date_expr1.dateexpr2)日期差
    dateadd(datepart,number,date_expr)返回日期加上number

    上述函數(shù)中datepart的
    寫法取值和意義
    yy1753-9999年份
    qq1-4刻
    mm1-12月
    dy1-366日
    dd1-31日
    wk1-54周
    dw1-7周幾
    hh0-23小時(shí)
    mi0-59分鐘
    ss0-59秒
    ms0-999毫秒

    日期轉(zhuǎn)換
    convert()

    4.系統(tǒng)函數(shù)
    suser_name()用戶登錄名
    user_name()用戶在數(shù)據(jù)庫(kù)中的名字
    user用戶在數(shù)據(jù)庫(kù)中的名字
    show_role()對(duì)當(dāng)前用戶起作用的規(guī)則
    db_name()數(shù)據(jù)庫(kù)名
    object_name(obj_id)數(shù)據(jù)庫(kù)對(duì)象名
    col_name(obj_id,col_id)列名
    col_length(objname,colname)列長(zhǎng)度
    valid_name(char_expr)是否是有效標(biāo)識(shí)符

    posted @ 2007-03-09 09:23 lubaolin 閱讀(369) | 評(píng)論 (0)編輯 收藏

    1. JFrame對(duì)象一般可以直接向里面添加數(shù)據(jù),但是在設(shè)置背景顏色時(shí)得用:Container f = new JFrame(“test”).getContentPane();

    2. pack()是設(shè)置窗體大小自適應(yīng)其內(nèi)組件,setSize()為設(shè)置其顯示的大小。

    3. 默認(rèn)關(guān)閉窗體JFrame時(shí),是隱藏。要想真退出。請(qǐng)加入setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFrame.EXIT_ON_CLOSE是一整形常量,值為3。

    4. 加載GIF圖片:
    MediaTracker tracker = new MediaTracker(this);
    Image img = new ImageIcon (getClass().getResource(“test.gif”)).getImage():
    Tracker.addImage(img,0):
    try{
    ? tracker.waitForAll();
    ?}catch(Exception e)
    {}
    此后就可以對(duì)完整的gif進(jìn)行操作了。

    5. 光標(biāo)移動(dòng)到組件上給出提示:setToolTipText(”this is tip”);

    6. JScrollPane可以通過(guò)setVerticalScrollBarPolicy(int policy)
    和setHorizontalScrollBarPolicy(int policy)來(lái)選擇是否顯示滾動(dòng)條。

    7.彈出消息框:JOptionPane.showMessageDialog(btn,new String (“test”));
    彈出錯(cuò)誤提示:JOptionPane.showMessageDialog(null,"錯(cuò)誤信息","錯(cuò)誤框標(biāo)題",JOptionPane.ERROR_MESSAGE);

    8. 文本輸入框右對(duì)齊:SetHorizontalAlignment(JTextField.RIGHT);

    9.? 讀取JAR包內(nèi)資源,應(yīng)該使用:getClass().getResource();

    10. 容器布局為空后——setLayout(null),其內(nèi)組件應(yīng)setBounds();

    11.內(nèi)存回收:if(Runtime.getRuntime().freeMemory()<Runtime.getRuntime().totalMemory()/3)
    {
    ?System.gc();
    }

    12.? JFrame 窗口不可最大化:setResizable(false);

    13. 應(yīng)用程序和applet小程序共存:直接把a(bǔ)pplet往jframe里面加就成應(yīng)用程序。

    14. 讓窗口居中(屏幕)顯示:setLocationRelativeTo(null):
    或者用:
    Toolkit kit = Toolkit.getDefaultToolkit():
    Dimension screenSize = kit.getScreenSize();
    f.setLocation((screenSize.Width-f.getWidth())/2, (screenSize.Height-f.getHeight())/2);

    15. 選擇皮膚感官:
    try{
    UIManager.setLookAndFeel ( "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
    ??????????? SwingUtilities.updateComponentTreeUI(f);
    }

    16. 密碼框可設(shè)setEchoChar(‘#’);或者密碼時(shí) pwd = new String(password.getPassword());

    17. 用JlayeredPane添加組件時(shí)候可以設(shè)置深度。

    18. 區(qū)別單雙擊事件:
    if(e.getClickCount ==1)
    {}else if(e.getClickCount ==2){}

    19. JAVA2D 中設(shè)置虛線:
    float [] dash = {2.0f,4.0f};
    g2.setStroke(
    new BasicStroke(2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_BEVEL,2.0f,dash,2.0f));

    20. JAVA2D 中設(shè)置字體筆畫大小:
    Font cf = g.getFont();
    Font newf = new Font(cf.getName(),cf.getStyle(),cf.getSize()+20);
    g.setFont(newf);

    21.讓樹(shù)無(wú)圖標(biāo)標(biāo)簽
    ((DefaultTreeCellRenderer)tree.getCellRenderer()).setOpenIcon(null);
    ((DefaultTreeCellRenderer)tree.getCellRenderer()).setClosedIcon(null);
    ((DefaultTreeCellRenderer)tree.getCellRenderer()).setDisabledIcon(null);
    ((DefaultTreeCellRenderer)tree.getCellRenderer()).setLeafIcon(null);

    22.豎著顯示滑塊
    new JSlider(SwingConstants.VERTICAL,min,max,initialValue);

    23.通過(guò)標(biāo)尺顯示滑塊
    slider.setMajorTickSpacing(20);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);

    24.讓滑塊自動(dòng)對(duì)齊到標(biāo)尺
    slider.setSnapToTicks(true);

    25.滑塊事件
    addChangeListener
    ChangeListener -> stateChanged(ChangeEvent event)

    26.滑塊標(biāo)尺特殊化
    HashtMap map = new HashMap();
    map.put(new Integer(0),new JLabel("A"));
    slider.setLabel(map);

    27.多選單選按鈕
    JCheckBox 和 JRadioButton 其中單選放入ButtonGroup對(duì)象中。
    判斷是否選中:isSelected()
    獲取標(biāo)簽用:getText();
    事件:ItemListener
    方法:itemStateChanged(ItemEvent event)

    28.讓樹(shù)一開(kāi)始就全部展開(kāi)
    expandAll(tree,new TreePath(tree.getModel().getRoot()));
    其中有:
    public void expandAll (JTree tree,TreePath path)
    {
    ??? tree.expandPath(path);
    ??? Obect parent = path.getLastPathComponent();
    ??? TreeModel model = tree.getModel()
    ??? if(model ==null)return;
    ??? if(model.isLeaf(parent)) return;
    ??? int size = model.getChildCount(parent);
    ??? for(int i = 0 ;i<size;i++)
    ??? {
    ??????? Object child = model.getChild(parent,i);
    ??????? expandAll(tree,path.pathByAddingChild(child));
    ??? }
    }

    29.樹(shù)節(jié)點(diǎn)匹配:
    TreePath path = tree.getNextMatch(str,0,Positon.Bias.Forward);
    if(path !=null)
    {
    ??? tree.setSelectionPath(path);
    }

    30.獲取樹(shù)節(jié)點(diǎn)

    TreeSelectionListener->valueChanged(TreeSelectionEvent e)
    TreePath path = e.getPath();
    String info = path.getLastPathComponent().toString();
    而這里獲取到是最后那個(gè)選擇節(jié)點(diǎn),如成都。
    JTree tree = (JTree)e.getSource();
    TreePath tp= tree.getPathForLorLocation(e.getPoint().x,e.getPoint().y);
    這個(gè)PATH是完整的節(jié)點(diǎn)名,比如:四川,成都

    31.截屏程序核心:
    BufferedImage fullScreenImage = robot.createScreenCapture (new Rectangle (
    ??????????????? Toolkit.getDefaultToolkit ().getScreenSize ()));
    ??????? ImageIcon icon = new ImageIcon (fullScreenImage);
    利用 fullScreenImage.getSubimage(int x,int y,int w,int h)得到子圖象(其中的矩形范圍是鼠標(biāo)拖動(dòng)事件而得到)
    ImageIO.write (fullScreenImage.getSubimage(int x,int y,int w,int h),"png","out.png");

    界面上:1.繼承JLabel 覆蓋起paint方法;
    ?? ?2.JPanel 從(JPanel)Dialog.getContentPane()來(lái),JLabel 添加進(jìn)JPanel;
    ?? ?3.Dialog設(shè)置為屏幕大小、不顯示邊框等飾物dialog.setUndecorated (true);(JFrame中其實(shí)也有這個(gè)方法。)
    ?? ?4.設(shè)置十字光標(biāo),dialog.setCursor (Cursor.getPredefinedCursor (Cursor.CROSSHAIR_CURSOR));
    ??????? 5.設(shè)置為模態(tài) dialog.setModal (true);

    轉(zhuǎn)自:http://m.tkk7.com/JAVA-HE/archive/2007/02/06/98338.aspx

    posted @ 2007-03-07 09:52 lubaolin 閱讀(455) | 評(píng)論 (0)編輯 收藏

    用Acegi為你的Spring應(yīng)用加把鎖!
    [簡(jiǎn)介]
    對(duì)于一個(gè)典型的Web應(yīng)用,完善的認(rèn)證和授權(quán)機(jī)制是必不可少的,在SpringFramework中,Juergen Hoeller提供的范例JPetStore給了一些這方面的介紹,但還遠(yuǎn)遠(yuǎn)不夠,Acegi是一個(gè)專門為SpringFramework提供安全機(jī)制的項(xiàng)目,全稱為Acegi Security System for Spring,當(dāng)前版本為0.5.1,就其目前提供的功能,應(yīng)該可以滿足絕大多數(shù)應(yīng)用的需求。

    本文的主要目的是希望能夠說(shuō)明如何在基于Spring構(gòu)架的Web應(yīng)用中使用Acegi,而不是詳細(xì)介紹其中的每個(gè)接口、每個(gè)類。注意,即使對(duì)已經(jīng)存在的Spring應(yīng)用,通過(guò)下面介紹的步驟,也可以馬上享受到Acegi提供的認(rèn)證和授權(quán)。

    [基礎(chǔ)工作]
    在你的Web應(yīng)用的lib中添加Acegi下載包中的acegi-security.jar

    [web.xml]
    實(shí)現(xiàn)認(rèn)證和授權(quán)的最常用的方法是通過(guò)filter,Acegi亦是如此,通常Acegi需要在web.xml添加以下5個(gè)filter:

    <filter>
    ? <filter-name>Acegi Channel Processing Filter</filter-name>
    ? <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
    ? <init-param>
    ??? <param-name>targetClass</param-name>
    ??? <param-value>net.sf.acegisecurity.securechannel.ChannelProcessingFilter</param-value>
    ? </init-param>
    </filter>
    <filter>
    ? <filter-name>Acegi Authentication Processing Filter</filter-name>
    ? <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
    ? <init-param>
    ??? <param-name>targetClass</param-name>
    ??? <param-value>net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilter</param-value>
    ? </init-param>
    </filter>
    <filter>
    ? <filter-name>Acegi HTTP BASIC Authorization Filter</filter-name>
    ? <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
    ? <init-param>
    ??? <param-name>targetClass</param-name>
    ??? <param-value>net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter</param-value>
    ? </init-param>
    </filter>
    <filter>
    ? <filter-name>Acegi Security System for Spring Auto Integration Filter</filter-name>
    ? <filter-class>net.sf.acegisecurity.ui.AutoIntegrationFilter</filter-class>
    </filter>
    <filter>
    ? <filter-name>Acegi HTTP Request Security Filter</filter-name>
    ? <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
    ? <init-param>
    ??? <param-name>targetClass</param-name>
    ??? <param-value>net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter</param-value>
    ? </init-param>
    </filter>

    最先引起迷惑的是net.sf.acegisecurity.util.FilterToBeanProxy,Acegi自己的文檔上解釋是: “What? FilterToBeanProxy does is delegate the Filter's methods through to a bean which is obtained from the
    Spring application context. This enables the bean to benefit from the Spring application context lifecycle support and configuration flexibility.”,如希望深究的話,去看看源代碼應(yīng)該不難理解。

    再下來(lái)就是添加filter-mapping了:
    <filter-mapping>
    ? <filter-name>Acegi Channel Processing Filter</filter-name>
    ? <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    ? <filter-name>Acegi Authentication Processing Filter</filter-name>
    ? <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    ? <filter-name>Acegi HTTP BASIC Authorization Filter</filter-name>
    ? <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    ? <filter-name>Acegi Security System for Spring Auto Integration Filter</filter-name>
    ? <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    ? <filter-name>Acegi HTTP Request Security Filter</filter-name>
    ? <url-pattern>/*</url-pattern>
    </filter-mapping>

    這里,需要注意以下兩點(diǎn):
    1) 這幾個(gè)filter的順序是不能更改的,順序不對(duì)將無(wú)法正常工作;
    2) 如果你的應(yīng)用不需要安全傳輸,如https,則將"Acegi Channel Processing Filter"相關(guān)內(nèi)容注釋掉即可;
    3) 如果你的應(yīng)用不需要Spring提供的遠(yuǎn)程訪問(wèn)機(jī)制,如Hessian and Burlap,將"Acegi HTTP BASIC Authorization
    Filter"相關(guān)內(nèi)容注釋掉即可。

    [applicationContext.xml]
    接下來(lái)就是要添加applicationContext.xml中的內(nèi)容了,從剛才FilterToBeanFactory的解釋可以看出,真正的filter都
    在Spring的applicationContext中管理:

    1) 首先,你的數(shù)據(jù)庫(kù)中必須具有保存用戶名和密碼的table,Acegi要求table的schema必須如下:

    CREATE TABLE users (
    ??? username VARCHAR(50) NOT NULL PRIMARY KEY,
    ??? password VARCHAR(50) NOT NULL,
    ??? enabled BIT NOT NULL
    );
    CREATE TABLE authorities (
    ??? username VARCHAR(50) NOT NULL,
    ??? authority VARCHAR(50) NOT NULL
    );
    CREATE UNIQUE INDEX ix_auth_username ON authorities ( username, authority );
    ALTER TABLE authorities ADD CONSTRAINT fk_authorities_users foreign key (username) REFERENCES users
    (username);

    2) 添加訪問(wèn)你的數(shù)據(jù)庫(kù)的datasource和Acegi的jdbcDao,如下:

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    ? <property name="driverClassName"><value>${jdbc.driverClassName}</value></property>
    ? <property name="url"><value>${jdbc.url}</value></property>
    ? <property name="username"><value>${jdbc.username}</value></property>
    ? <property name="password"><value>${jdbc.password}</value></property>
    </bean>
    <bean id="jdbcDaoImpl" class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
    ? <property name="dataSource"><ref bean="dataSource"/></property>
    </bean>

    3) 添加DaoAuthenticationProvider:

    <bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
    ? <property name="authenticationDao"><ref bean="authenticationDao"/></property>
    ? <property name="userCache"><ref bean="userCache"/></property>
    </bean>

    <bean id="userCache" class="net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
    ? <property name="minutesToIdle"><value>5</value></property>
    </bean>

    如果你需要對(duì)密碼加密,則在daoAuthenticationProvider中加入:<property name="passwordEncoder"><ref
    bean="passwordEncoder"/></property>,Acegi提供了幾種加密方法,詳細(xì)情況可看包
    net.sf.acegisecurity.providers.encoding

    4) 添加authenticationManager:

    <bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
    ? <property name="providers">
    ??? <list>
    ????? <ref bean="daoAuthenticationProvider"/>
    ??? </list>
    ?? </property>
    </bean>

    5) 添加accessDecisionManager:

    <bean id="accessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
    ? <property name="allowIfAllAbstainDecisions">
    ??? <value>false</value>
    ? </property>
    ? <property name="decisionVoters">
    ??? <list><ref bean="roleVoter"/></list>
    ? </property>
    </bean>
    <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>

    6) 添加authenticationProcessingFilterEntryPoint:

    <bean id="authenticationProcessingFilterEntryPoint"
    class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
    ? <property name="loginFormUrl"><value>/acegilogin.jsp</value></property>
    ? <property name="forceHttps"><value>false</value></property>
    </bean>

    其中acegilogin.jsp是登陸頁(yè)面,一個(gè)最簡(jiǎn)單的登錄頁(yè)面如下:

    <%@ taglib prefix='c' uri='http://java.sun.com/jstl/core' %>
    <%@ page import="net.sf.acegisecurity.ui.AbstractProcessingFilter" %>
    <%@ page import="net.sf.acegisecurity.AuthenticationException" %>
    <html>
    ? <head>
    ??? <title>Login</title>
    ? </head>

    ? <body>
    ??? <h1>Login</h1>
    ??? <form action="<c:url value='j_acegi_security_check'/>" method="POST">
    ????? <table>
    ??????? <tr><td>User:</td><td><input type='text' name='j_username'></td></tr>
    ??????? <tr><td>Password:</td><td><input type='password' name='j_password'></td></tr>
    ??????? <tr><td colspan='2'><input name="submit" type="submit"></td></tr>
    ??????? <tr><td colspan='2'><input name="reset" type="reset"></td></tr>
    ????? </table>
    ??? </form>
    ? </body>
    </html>

    7) 添加filterInvocationInterceptor:

    <bean id="filterInvocationInterceptor"
    class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
    ? <property name="authenticationManager">
    ??? <ref bean="authenticationManager"/>
    ? </property>
    ? <property name="accessDecisionManager">
    ??? <ref bean="accessDecisionManager"/>
    ? </property>
    ? <property name="objectDefinitionSource">
    ??? <value>
    ????? CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    ????? \A/sec/administrator.*\Z=ROLE_SUPERVISOR
    ????? \A/sec/user.*\Z=ROLE_TELLER
    ??? </value>
    ? </property>
    </bean>

    這里請(qǐng)注意,要objectDefinitionSource中定義哪些頁(yè)面需要權(quán)限訪問(wèn),需要根據(jù)自己的應(yīng)用需求進(jìn)行修改,我上面給出
    的定義的意思是這樣的:
    ?a. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON意思是在比較請(qǐng)求路徑時(shí)全部轉(zhuǎn)換為小寫
    ?b. \A/sec/administrator.*\Z=ROLE_SUPERVISOR意思是只有權(quán)限為ROLE_SUPERVISOR才能訪問(wèn)/sec/administrator*的頁(yè)面
    ?c. \A/sec/user.*\Z=ROLE_TELLER意思是只有權(quán)限為ROLE_TELLER的用戶才能訪問(wèn)/sec/user*的頁(yè)面

    8) 添加securityEnforcementFilter:

    <bean id="securityEnforcementFilter" class="net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter">
    ? <property name="filterSecurityInterceptor">
    ??? <ref bean="filterInvocationInterceptor"/>
    ? </property>
    ? <property name="authenticationEntryPoint">
    ??? <ref bean="authenticationProcessingFilterEntryPoint"/>
    ? </property>
    </bean>

    9) 添加authenticationProcessingFilter:

    <bean id="authenticationProcessingFilter"
    class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
    ? <property name="authenticationManager">
    ??? <ref bean="authenticationManager"/>
    ? </property>
    ? <property name="authenticationFailureUrl">
    ??? <value>/loginerror.jsp</value>
    ? </property>
    ? <property name="defaultTargetUrl">
    ??? <value>/</value>
    ? </property>
    ? <property name="filterProcessesUrl">
    ??? <value>/j_acegi_security_check</value>
    ? </property>
    </bean>
    其中authenticationFailureUrl是認(rèn)證失敗的頁(yè)面。

    10) 如果需要一些頁(yè)面通過(guò)安全通道的話,添加下面的配置:

    <bean id="channelProcessingFilter" class="net.sf.acegisecurity.securechannel.ChannelProcessingFilter">
    ? <property name="channelDecisionManager">
    ??? <ref bean="channelDecisionManager"/>
    ? </property>
    ? <property name="filterInvocationDefinitionSource">
    ??? <value>
    ????? CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    ????? \A/sec/administrator.*\Z=REQUIRES_SECURE_CHANNEL
    ????? \A/acegilogin.jsp.*\Z=REQUIRES_SECURE_CHANNEL
    ????? \A/j_acegi_security_check.*\Z=REQUIRES_SECURE_CHANNEL
    ????? \A.*\Z=REQUIRES_INSECURE_CHANNEL
    ??? </value>
    ? </property>
    </bean>

    <bean id="channelDecisionManager" class="net.sf.acegisecurity.securechannel.ChannelDecisionManagerImpl">
    ? <property name="channelProcessors">
    ??? <list>
    ????? <ref bean="secureChannelProcessor"/>
    ????? <ref bean="insecureChannelProcessor"/>
    ??? </list>
    ? </property>
    </bean>
    <bean id="secureChannelProcessor" class="net.sf.acegisecurity.securechannel.SecureChannelProcessor"/>
    <bean id="insecureChannelProcessor" class="net.sf.acegisecurity.securechannel.InsecureChannelProcessor"/>

    [缺少了什么?]
    Acegi目前提供了兩種"secure object",分別對(duì)頁(yè)面和方法進(jìn)行安全認(rèn)證管理,我這里介紹的只是利用
    FilterSecurityInterceptor對(duì)訪問(wèn)頁(yè)面的權(quán)限控制,除此之外,Acegi還提供了另外一個(gè)Interceptor——
    MethodSecurityInterceptor,它結(jié)合runAsManager可實(shí)現(xiàn)對(duì)對(duì)象中的方法的權(quán)限控制,使用方法可參看Acegi自帶的文檔
    和contact范例。

    [最后要說(shuō)的]
    本來(lái)以為只是說(shuō)明如何使用Acegi而已,應(yīng)該非常簡(jiǎn)單,但真正寫起來(lái)才發(fā)現(xiàn)想要條理清楚的理順?biāo)行枰腷ean還是很
    困難的,但愿我沒(méi)有遺漏太多東西,如果我的文章有什么遺漏或錯(cuò)誤的話,還請(qǐng)參看Acegi自帶的quick-start范例,但請(qǐng)
    注意,這個(gè)范例是不能直接拿來(lái)用的。

    posted @ 2007-03-06 09:28 lubaolin 閱讀(259) | 評(píng)論 (0)編輯 收藏

    <SCRIPT>
    var imagepath="10cfeba177b.jpg"
    var imagewidth=200 //這兩行寫圖片的大小
    var imageheight=300
    var speed=2;
    var imageclick="index0.htm" //這里寫點(diǎn)擊圖片連接到的地址
    var hideafter=0
    var isie=0;
    if(window.navigator.appName=="Microsoft Internet Explorer"&&window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE")+5,window.navigator.appVersion.indexOf("MSIE")+8)>=5.5) {
    isie=1;
    }
    else {
    isie=0;
    }
    if(isie){
    var preloadit=new Image()
    preloadit.src=imagepath
    }
    function pop() {
    if(isie) {
    x=x+dx;y=y+dy;
    oPopup.show(x, y, imagewidth, imageheight);
    if(x+imagewidth+5>screen.width) dx=-dx;
    if(y+imageheight+5>screen.height) dy=-dy;
    if(x<0) dx=-dx;
    if(y<0) dy=-dy;
    startani=setTimeout("pop();",50);
    }
    }
    function dismisspopup(){
    clearTimeout(startani)
    oPopup.hide()
    }
    function dowhat(){
    if (imageclick=="dismiss")
    dismisspopup()
    else
    window.open(imageclick);
    }
    if(isie) {
    var x=0,y=0,dx=speed,dy=speed;
    var oPopup = window.createPopup();
    var oPopupBody = oPopup.document.body;
    oPopupBody.style.cursor="hand"
    oPopupBody.innerHTML = '<IMG SRC="'+preloadit.src+'">';
    oPopup.document.body.onmouseover=new Function("clearTimeout(startani)")
    oPopup.document.body.onmouseout=pop
    oPopup.document.body.onclick=dowhat
    pop();
    if (hideafter>0)
    setTimeout("dismisspopup()",hideafter*1000)
    }
    </SCRIPT>

    posted @ 2007-02-08 18:01 lubaolin 閱讀(5000) | 評(píng)論 (2)編輯 收藏

    繼續(xù)關(guān)注我的C語(yǔ)言學(xué)習(xí)博客
    主站蜘蛛池模板: 久久综合日韩亚洲精品色| 1000部啪啪未满十八勿入免费| 亚洲国产成人久久精品app| 亚洲成a人片在线观看老师| 手机看黄av免费网址| 可以免费观看的国产视频| 九九九精品视频免费| 亚洲欧洲专线一区| 亚洲老熟女@TubeumTV| 亚洲综合AV在线在线播放| 日美韩电影免费看| 三年片在线观看免费观看高清电影 | 亚洲?V无码成人精品区日韩| 国产成在线观看免费视频| 久久午夜无码免费| 日本道免费精品一区二区| www在线观看免费视频| 猫咪www免费人成网站| 久久精品国产亚洲av天美18| 亚洲精品亚洲人成在线播放| 亚洲第一网站免费视频| 久久久久亚洲Av无码专| 青青草原精品国产亚洲av| 国产成人A人亚洲精品无码| 337p日本欧洲亚洲大胆裸体艺术| www国产亚洲精品久久久日本| 国产网站在线免费观看| 在线播放免费播放av片| 搡女人免费视频大全| 在线观看免费人成视频色9| 麻豆一区二区免费播放网站| 亚洲免费在线观看视频| 久久国产免费福利永久| 久久受www免费人成_看片中文| 亚洲电影在线免费观看| 国产成人精品免费午夜app| 在线看片韩国免费人成视频| 免费国产作爱视频网站| 成人毛片18女人毛片免费| 日韩在线看片免费人成视频播放| 四虎影院在线免费播放|