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

          林臨的地盤(pán)

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

          2007年3月9日

          struts2的s:iterator 可以遍歷 數(shù)據(jù)棧里面的任何數(shù)組,集合等等 以下幾個(gè)簡(jiǎn)單的demo:
          s:iterator 標(biāo)簽有3個(gè)屬性:
              value:被迭代的集合
              id   :指定集合里面的元素的id
              status 迭代元素的索引
          1:jsp頁(yè)面定義元素寫(xiě)法 數(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ì)象
          遍歷寫(xiě)法如下:
          <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類(lèi),
          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 還可以寫(xiě)成 value="%{label}" label可以有.操作
          label的屬性List 可以寫(xiě)成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://www.aygfsteel.com/Reg/archive/2009/11/20/303085.html

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

          點(diǎn)擊“開(kāi)始→運(yùn)行”,在彈出的“運(yùn)行”對(duì)話框中輸入“REGSVR32 /n /i:u shell32”(不含雙引號(hào)),然后回車(chē),片刻后會(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 閱讀(8840) | 評(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 閱讀(723) | 評(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 閱讀(21248) | 評(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)建用戶(hù)并指定表空間
          create user username identified by password
          default tablespace test_data
          temporary tablespace test_temp;

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

          grant connect,resource to username;

          //以后以該用戶(hù)登錄,創(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 閱讀(368) | 評(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類(lèi),具備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 閱讀(2668) | 評(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 閱讀(921) | 評(píng)論 (0)編輯 收藏

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

          posted @ 2008-07-21 14:34 lubaolin 閱讀(402) | 評(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 閱讀(1069) | 評(píng)論 (0)編輯 收藏

          Spring的依賴(lài)關(guān)系
          依賴(lài)關(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ì)大量不同種類(lèi)的協(xié)議包括Caucho的Burlap和Hessian提供了支持。要用哪個(gè)協(xié)議就包含這個(gè)分組里相應(yīng)的JAR文件。
          cglib
          cglib-full-2.0.2.jar
          CGLIB用來(lái)生成動(dòng)態(tài)代理類(lè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í)用類(lèi)的集合,對(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模板引擎的包裝類(lèi),還為把FreeMarker模板用作web應(yīng)用的視圖提供了支持。只要使用FreeMarker,就需要這個(gè)JAR文件。
          hibernate
          ehcache.jar, hibernate2.jar, odmg.jar
          如果采用Spring的Hibernate集成和支持類(lèi),這些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集成類(lèi)時(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)來(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類(lèi)時(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的包裝類(lèi)使其支持DI,同時(shí)當(dāng)你在應(yīng)用中使用Velocity時(shí),還可減少需要編寫(xiě)的代碼量。除此之外,Spring還提供了一些類(lèi),支持將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://www.aygfsteel.com/linlin2005");
               imgUrl2="/images/2.jpg";
               imgtext2="ite"
               imgLink2=escape("http://www.aygfsteel.com/linlin2005");
               imgUrl3="/images/3.jpg";
               imgtext3="ite"
               imgLink3=escape("http://www.aygfsteel.com/linlin2005");
               imgUrl4="/images/4.jpg";
               imgtext4="ite"
               imgLink4=escape("http://www.aygfsteel.com/linlin2005");
               imgUrl5="/images/5.jpg";
               imgtext5="ite"
               imgLink5=escape("http://www.aygfsteel.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 閱讀(520) | 評(píng)論 (0)編輯 收藏

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

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

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

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

          3. 執(zhí)行查詢(xún)語(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ù)表名)是大小寫(xiě)敏感的,如果寫(xiě)成user是查不到結(jié)果的。

           引自:http://www.aygfsteel.com/afrag/

          posted @ 2007-08-01 17:19 lubaolin 閱讀(4822) | 評(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 閱讀(1562) | 評(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 閱讀(8126) | 評(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 閱讀(1666) | 評(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配置,在寫(xiě)入配置文件之前,用戶(hù)必須將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> <!—連接池的別名可以隨便寫(xiě),但注意的是后面在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í)的銷(xiāo)毀-->

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

          <!--指因未有空閑連接可以分配而在隊(duì)列中等候的最大請(qǐng)求數(shù),超過(guò)這個(gè)請(qǐng)求數(shù)的用戶(hù)連接就不會(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),專(zhuān)心研究業(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) 
          先寫(xiě)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í)的銷(xiāo)毀--> 
          <house-keeping-sleep-time>90000</house-keeping-sleep-time>

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

          用戶(hù)連接就不會(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的連接加載類(lèi),這里Proxool連接池是用這個(gè),不同的連接池有不同的加載類(lèi),可以查閱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類(lèi)的一個(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 閱讀(7668) | 評(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 閱讀(557) | 評(píng)論 (1)編輯 收藏

          bin>mysql -u root
          mysql> grant 權(quán)限1,權(quán)限2,…權(quán)限n on 數(shù)據(jù)庫(kù)名稱(chēng).表名稱(chēng) to 用戶(hù)名@用戶(hù)地址 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代替,表示賦予用戶(hù)全部權(quán)限。
          當(dāng)數(shù)據(jù)庫(kù)名稱(chēng).表名稱(chēng)被*.*代替,表示賦予用戶(hù)操作服務(wù)器上所有數(shù)據(jù)庫(kù)所有表的權(quán)限。
          用戶(hù)地址可以是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的用戶(hù)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的用戶(hù)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的用戶(hù)joe分配可對(duì)所有數(shù)據(jù)庫(kù)的所有表進(jìn)行所有操作的權(quán)限,并設(shè)定口令為123。

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

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

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


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


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

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

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

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


          b)showrs.jsp中寫(xiě):

          <%@ 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 閱讀(2879) | 評(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  以用戶(hù) 通過(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ù)需要,顯式地以用戶(hù) 和密碼 與數(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)前用戶(hù)的表。
          describe table  顯示一個(gè)表或視圖的列信息。
          list tablespaces [show detail] 顯示表空間的標(biāo)識(shí)、名稱(chēng)、類(lèi)型、內(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í)例的正常快照信息(僅適用于 V8)。
          get health snapshot for all on  返回?cái)?shù)據(jù)庫(kù) 的所有正常快照(僅適用于 V8)。

           

          管理服務(wù)器

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

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

          1、查看表空間的名稱(chēng)及大小
          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、查看表空間物理文件的名稱(chēng)及大小
          select tablespace_name, file_id, file_name,
          round(bytes/(1024*1024),0) total_space
          from dba_data_files
          order by tablespace_name;

          3、查看回滾段名稱(chēng)及大小
          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分類(lèi)數(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、按用戶(hù)查看object種類(lèi)
          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)查看有哪些用戶(hù)連接
          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、查詢(xún)表空間使用情況select a.tablespace_name "表空間名稱(chēng)",
          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、 查詢(xún)表空間的碎片程度
          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è)字符

          字符操作類(lèi)
          upper(char_expr)轉(zhuǎn)為大寫(xiě)
          lower(char_expr)轉(zhuǎn)為小寫(xiě)
          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)返回名稱(chēng)如June
          datepart(datepart,date_expr)取日期一部份
          datediff(datepart,date_expr1.dateexpr2)日期差
          dateadd(datepart,number,date_expr)返回日期加上number

          上述函數(shù)中datepart的
          寫(xiě)法取值和意義
          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()用戶(hù)登錄名
          user_name()用戶(hù)在數(shù)據(jù)庫(kù)中的名字
          user用戶(hù)在數(shù)據(jù)庫(kù)中的名字
          show_role()對(duì)當(dāng)前用戶(hù)起作用的規(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 閱讀(371) | 評(píng)論 (0)編輯 收藏

          繼續(xù)關(guān)注我的C語(yǔ)言學(xué)習(xí)博客
          主站蜘蛛池模板: 滨海县| 潍坊市| 岑溪市| 鸡泽县| 左贡县| 昌平区| 丘北县| 宿迁市| 清原| 象山县| 交口县| 随州市| 定西市| 璧山县| 图木舒克市| 灵山县| 新津县| 拉孜县| 张掖市| 大厂| 香格里拉县| 荔浦县| 夏邑县| 阳城县| 正镶白旗| 青龙| 宜州市| 聊城市| 贵定县| 噶尔县| 惠安县| 满城县| 凭祥市| 成安县| 临洮县| 邯郸县| 长兴县| 长乐市| 清丰县| 汶上县| 梓潼县|