Terry.Li-彬

          虛其心,可解天下之問;專其心,可治天下之學(xué);靜其心,可悟天下之理;恒其心,可成天下之業(yè)。

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            143 隨筆 :: 344 文章 :: 130 評論 :: 0 Trackbacks
           

          工作流下載地址http://sourceforge.net/project/downloading.php?group_id=70542&use_mirror=jaist&filename=jbpm-jpdl-suite-3.2.1.zip&5744684

          sheclipse里面啟動tomcat+db2項(xiàng)目,報錯:不能找到db2

          解決方法:在eclipse 中配置tomcat中加入如下語句

          -Djava.library.path=D:"Java"IBM"SQLLIB"BIN

          Linux命令

          查看文本

          Vi

          退出vi編輯

          Esc -> :q

          動態(tài)查看日志文件

          Tail –f 文件名

          Linux下命令啟動ldap

          [root@sl /]# cd /etc/init.d/

          [root@sl init.d]# pwd

          /etc/init.d

          [root@sl init.d]# ./ldap stop

          停止 slapd                                               [ 確定 ]

          [root@sl init.d]# ./ldap start

          檢查 的配置文件:config file testing succeeded

          啟動 slapd                                               [ 確定 ]

          [root@sl init.d]# ./ldap restart

          停止 slapd                                               [ 確定 ]

          檢查 slapd 的配置文件:config file testing succeeded

          啟動 slapd                                               [ 確定 ]

          [root@sl init.d]# pwd

          /etc/init.d

          [root@sl init.d]#

          方法二:

          如果ldap服務(wù)器配置好了,用下面命令可以啟動

          Service ldap restart

          Service ldap start

          Service ldap stop

          linux下查看ldap的調(diào)用方法

          [root@sl init.d]# ./ldap help

          用法:./ldap {start|stop|restart|status|condrestart}

          org/hibernate/cfg/HbmBinder$SecondPass 錯誤

          在練習(xí)SSH框架的時候出現(xiàn)如下錯誤:

          org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactoryId' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass

          java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass

                 at java.lang.ClassLoader.defineClass1(Native Method)

                 at java.lang.ClassLoader.defineClass(ClassLoader.java:620)

                 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

                 at

          原因是項(xiàng)目中hibernate.jar hibernate-annotations.jar兩個包的版本低

          解決方法:1、直接刪除hibernate-annotations.jar

                    2、將這兩個包替換為最新的

          Windows下啟動ldap

          Slapd –d 1

          -ivf

          -ivh

          linux下啟動ssh

          /etc/init.d/./sshd restart

          配置root用戶可否訪問

          /etc/ssh/

          Vi sshd_config

          linux下配置weblogic用戶域

          [root@sl bin]# pwd

          /bea/weblogic92/common/bin

          [root@sl bin]# ls

          commEnv.sh         quickstart.sh             stopPointBase.sh wlsifconfig.sh

          config_builder.sh startManagedWebLogic.sh   unpack.sh         wlst.sh

          config.sh          startPointBaseConsole.sh upgrade.sh

          pack.sh            startPointBase.sh         wlscontrol.sh

          [root@sl bin]# ./config.sh

          啟動監(jiān)聽 oracle用戶下執(zhí)行

          lsnrctl start

          >192.168.1.242

          現(xiàn)在好了。

          [oracle@localhost ~]$ lsnrctl start

          LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 31-1 -2007 15:12:34

          Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.

          Starting /opt/oracle/9.2.0/bin/tnslsnr: please wait...

          TNSLSNR for Linux: Version 9.2.0.4.0 - Production

          System parameter file is /opt/oracle/9.2.0/network/admin/listener.ora

          Log messages written to /opt/oracle/9.2.0/network/log/listener.log

          Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))

          Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

          Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))

          STATUS of the LISTENER

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

          Alias                     LISTENER

          Version                   TNSLSNR for Linux: Version 9.2.0.4.0 - Production

          Start Date                31-1 -2007 15:12:35

          Uptime                    0 days 0 hr. 0 min. 0 sec

          Trace Level               off

          Security                  OFF

          SNMP                      OFF

          Listener Parameter File   /opt/oracle/9.2.0/network/admin/listener.ora

          Listener Log File         /opt/oracle/9.2.0/network/log/listener.log

          Listening Endpoints Summary...

           (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))

           (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

          Services Summary...

          Service "PLSExtProc" has 1 instance(s).

           Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

          Service "futuredb" has 1 instance(s).

           Instance "futuredb", status UNKNOWN, has 1 handler(s) for this service...

          The command completed successfully

          查看linux正在使用的端口命令   netstat -an

          動態(tài)查看日志文件 tail -f 文件名

          解壓tar文件 tar -xvf 文件名.tar

          打包tar文件 tar -cvf 文件名.tar

          解壓gz文件   gunzip 文件名.gz

          解壓縮gz文件 gzip 文件名

          解壓cpio文件 cpio -idmv < *.cpio

          Struts中使用Spring代理找不到其他Spring配置文件中的定義,是因?yàn)橄到y(tǒng)在啟動時候首先加載Struts對應(yīng)的Config文件,通知加載該Config配置的插件Spring配置文件,如果Struts中只配置了本模塊對應(yīng)的Spring配置文件,而本Spring配置文件中又用到了其他的Spring配置文件的話,就發(fā)生找不到其他Spring配置文件中定義的bean,這時要將所有用到的Spring配置文件都配置在該Struts對應(yīng)的Config文件中,在系統(tǒng)啟動時候同時加載。

          <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">

                 <set-property property="contextConfigLocation" value="/WEB-INF/classes/conf/hibernate-context.xml,/WEB-INF/classes/conf/governmentinfo-context.xml"/>

              </plug-in>

          Struts中使用Spring代理,在Spring中配置Action的時候名稱應(yīng)該加上Struts的模塊名,例如:Kt 刊頭Action struts-config-governmentinfo.xml中定義的path名稱為 kt,將他配置到Spring配置文件中時候應(yīng)該加上Struts模塊名稱governmentinfo

          <bean name="/governmentinfo/kt"

                 class="com.futuresoftware.oa.governmentinfo.web.action.KtAction">

                 <property name="kt_service">

                     <ref local="ktManager"/>

                 </property>

              </bean>

          Linux 下掛載移動硬盤

          Mount –o iocharset=cp936 /dev/sdb1 /mnt/usb1

          Umount /mnt/usb1

          myeclipse+struts+tomcat下啟動tomcat出現(xiàn)以下錯誤:

          - Parsing error processing resource path

          java.net.UnknownHostException: struts.apache.org

              at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)

              at java.net.Socket.connect(Socket.java:507)

              at java.net.Socket.connect(Socket.java:457)

              at sun.net.NetworkClient.doConnect(NetworkClient.java:157)

              at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)

              at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)

          這是由于struts-config.xml中的dtd校驗(yàn)中的地址為http://struts.apache.org/dtds/struts-config_1_2.dtd,按照這個地址將struts-config_1_2.dtd下載后放到和struts-config.xml同一文件夾下,然后將struts-config.xml中替換為struts-config_1_2.dtd就可以了

          解決方法1、將struts-config.xml文件中的命名空間<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_1.dtd">

          中的1.2該為1.1就可以(這里項(xiàng)目用的是struts1.1

          Could not initialize proxy - the owning Session was closed

          是因?yàn)?/span>hibernate session關(guān)閉了,由于lazy=trueaction 中調(diào)用session.load()得到的對象是游離態(tài)的,不能修改,該方法要放在dao

          關(guān)于hibernatelazy問題詳解(經(jīng)典)

          Could not initialize proxy - the owning Session was closed (篇幅一)

          2007-05-11 09:52

          其實(shí)這個異常寫的非常之清楚,就是會話關(guān)閉,無法對Hibernate實(shí)體進(jìn)行操作。造成這樣的情況有很多,什么書寫錯誤啊,邏輯錯誤啊。

          但就此說一下關(guān)于lazy機(jī)制:

          延遲初始化錯誤是運(yùn)用Hibernate開發(fā)項(xiàng)目時最常見的錯誤。如果對一個類或者集合配置了延遲檢索策略,那么必須當(dāng)代理類實(shí)例或代理集合處于持久化狀態(tài)(即處于Session范圍內(nèi))時,才能初始化它。如果在游離狀態(tài)時才初始化它,就會產(chǎn)生延遲初始化錯誤。

          下面把Customer.hbm.xml文件的<class>元素的lazy屬性設(shè)為true,表示使用延遲檢索策略:

          <class name="mypack.Customer" table="CUSTOMERS" lazy="true">

          當(dāng)執(zhí)行
          Session的load()方法時,Hibernate不會立即執(zhí)行查詢CUSTOMERS表的select語句,僅僅返回Customer類的代理類的實(shí)例,這個代理類具由以下特征:

          (1) 由Hibernate在運(yùn)行時動態(tài)生成,它擴(kuò)展了Customer類,因此它繼承了Customer類的所有屬性和方法,但它的實(shí)現(xiàn)對于應(yīng)用程序是透明的。
          (2) 當(dāng)Hibernate創(chuàng)建Customer代理類實(shí)例時,僅僅初始化了它的OID屬性,其他屬性都為null,因此這個代理類實(shí)例占用的內(nèi)存很少。
          (3)當(dāng)應(yīng)用程序第一次訪問Customer代理類實(shí)例時(例如調(diào)用customer.getXXX()或customer.setXXX()方法), Hibernate會初始化代理類實(shí)例,在初始化過程中執(zhí)行select語句,真正從數(shù)據(jù)庫中加載Customer對象的所有數(shù)據(jù)。但有個例外,那就是當(dāng)應(yīng)用程序訪問Customer代理類實(shí)例的getId()方法時,Hibernate不會初始化代理類實(shí)例,因?yàn)樵趧?chuàng)建代理類實(shí)例時OID就存在了,不必到數(shù)據(jù)庫中去查詢。

          提示:Hibernate采用CGLIB工具來生成持久化類的代理類。CGLIB是一個功能強(qiáng)大的Java字節(jié)碼生成工具,它能夠在程序運(yùn)行時動態(tài)生成擴(kuò)展 Java類或者實(shí)現(xiàn)Java接口的代理類。關(guān)于CGLIB的更多知識,請參考:http://cglib.sourceforge.net/。

          以下代碼先通過
          Session的load()方法加載Customer對象,然后訪問它的name屬性:

          tx =
          session.beginTransaction();
          Customer customer=(Customer)
          session.load(Customer.class,new Long(1));
          customer.getName();
          tx.commit();

          在運(yùn)行session.load()方法時Hibernate不執(zhí)行任何select語句,僅僅返回Customer類的代理類的實(shí)例,它的OID為1,這是由load()方法的第二個參數(shù)指定的。當(dāng)應(yīng)用程序調(diào)用customer.getName()方法時,Hibernate會初始化Customer代理類實(shí)例,從數(shù)據(jù)庫中加載Customer對象的數(shù)據(jù),執(zhí)行以下select語句:

          select * from CUSTOMERS where ID=1;
          select * from ORDERS where CUSTOMER_ID=1;

          當(dāng)<class>元素的lazy屬性為true,會影響
          Session的load()方法的各種運(yùn)行時行為,下面舉例說明。

          1.如果加載的Customer對象在數(shù)據(jù)庫中不存在,
          Session的load()方法不會拋出異常,只有當(dāng)運(yùn)行customer.getName()方法時才會拋出以下異常:

          ERROR LazyInitializer:63
          - Exception initializing proxy
          net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 1, of class:
          mypack.Customer

          2
          .如果在整個Session范圍內(nèi),應(yīng)用程序沒有訪問過Customer對象,那么Customer代理類的實(shí)例一直不會被初始化,Hibernate不會執(zhí)行任何select語句。以下代碼試圖在關(guān)閉Session后訪問Customer游離對象:

          tx =
          session.beginTransaction();
          Customer customer=(Customer)
          session.load(Customer.class,new Long(1));
          tx.commit();
          session.close();
          customer.getName();

          由于引用變量customer引用的Customer代理類的實(shí)例在Session范圍內(nèi)始終沒有被初始化,因此在執(zhí)行customer.getName()方法時,Hibernate會拋出以下異常:

          ERROR LazyInitializer:63
          - Exception initializing proxy
          net.sf.hibernate.HibernateException: Couldnotinitializeproxy-theowningSessionwasclosed

          由此可見,Customer代理類的實(shí)例只有在當(dāng)前Session范圍內(nèi)才能被初始化。

          3.net.sf.hibernate.Hibernate類的
          initialize()靜態(tài)方法用于在Session范圍內(nèi)顯式初始化代理類實(shí)例,isInitialized()方法用于判斷代理類實(shí)例是否已經(jīng)被初始化。例如:

          tx =
          session.beginTransaction();
          Customer customer=(Customer)
          session.load(Customer.class,new Long(1));
          if(!Hibernate.isInitialized(customer))
          Hibernate.
          initialize(customer);
          tx.commit();
          session.close();
          customer.getName();

          以上代碼在Session范圍內(nèi)通過Hibernate類的initialize()方法顯式初始化了Customer代理類實(shí)例,因此當(dāng)Session關(guān)閉后,可以正常訪問Customer游離對象。

          4.當(dāng)應(yīng)用程序訪問代理類實(shí)例的getId()方法時,不會觸發(fā)Hibernate初始化代理類實(shí)例的行為,例如:

          tx =
          session.beginTransaction();
          Customer customer=(Customer)
          session.load(Customer.class,new Long(1));
          customer.getId();
          tx.commit();
          session.close();
          customer.getName();

          當(dāng)應(yīng)用程序訪問customer.getId()方法時,該方法直接返回Customer代理類實(shí)例的OID值,無需查詢數(shù)據(jù)庫。由于引用變量 customer始終引用的是沒有被初始化的Customer代理類實(shí)例,因此當(dāng)Session關(guān)閉后再執(zhí)行customer.getName()方法, Hibernate會拋出以下異常:

          ERROR LazyInitializer:63 - Exception initializing proxy
          net.sf.hibernate.HibernateException: Couldnotinitializeproxy-theowningSessionwasclosed

          解決方法:

          由于hibernate采用了lazy=true,這樣當(dāng)你用hibernate查詢時,返回實(shí)際為利用cglib增強(qiáng)的代理類,但其并沒有實(shí)際填充;當(dāng)你在前端,利用它來取值(getXXX)時,這時Hibernate才會到數(shù)據(jù)庫執(zhí)行查詢,并填充對象,但此時如果和這個代理類相關(guān)的session已關(guān)閉掉,就會產(chǎn)生種錯誤.
          在做一對多時,有時會出現(xiàn)"could not initialize proxy - clothe owning Session was sed,這個好像是hibernate的緩存問題.問題解決:需要在<many-to-one>里設(shè)置lazy="false". 但有可能會引發(fā)另一個異常叫

          failed to lazily initialize a collection of role: XXXXXXXX, no session or session was closed

          此異常解決方案請察看本人博客(http://hi.baidu.com/kekemao1)的Hibernate異常中的《failed to lazily initialize a collection of role異常》

          ?
          解決方法:在web.xml中加入
          <filter>
              <filter-name>hibernateFilter</filter-name>
              <filter-class>
               org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
              </filter-class>
          </filter
          <filter-mapping>
              <filter-name>hibernateFilter</filter-name>
              <url-pattern>*.do</url-pattern>
          </filter-mapping>
          就可以了;

          參考了:
          Hibernate與延遲加載:

          Hibernate對象關(guān)系映射提供延遲的與非延遲的對象初始化。非延遲加載在讀取一個對象的時候會將與這個對象所有相關(guān)的其他對象一起讀取出來。這有時會導(dǎo)致成百的(如果不是成千的話)select語句在讀取對象的時候執(zhí)行。這個問題有時出現(xiàn)在使用雙向關(guān)系的時候,經(jīng)常會導(dǎo)致整個數(shù)據(jù)庫都在初始化的階段被讀出來了。當(dāng)然,你可以不厭其煩地檢查每一個對象與其他對象的關(guān)系,并把那些最昂貴的刪除,但是到最后,我們可能會因此失去了本想在ORM工具中獲得的便利。


          一個明顯的解決方法是使用Hibernate提供的延遲加載機(jī)制。這種初始化策略只在一個對象調(diào)用它的一對多或多對多關(guān)系時才將關(guān)系對象讀取出來。這個過程對開發(fā)者來說是透明的,而且只進(jìn)行了很少的數(shù)據(jù)庫操作請求,因此會得到比較明顯的性能提升。這項(xiàng)技術(shù)的一個缺陷是延遲加載技術(shù)要求一個Hibernate會話要在對象使用的時候一直開著。這會成為通過使用DAO模式將持久層抽象出來時的一個主要問題。為了將持久化機(jī)制完全地抽象出來,所有的數(shù)據(jù)庫邏輯,包括打開或關(guān)閉會話,都不能在應(yīng)用層出現(xiàn)。最常見的是,一些實(shí)現(xiàn)了簡單接口的DAO實(shí)現(xiàn)類將數(shù)據(jù)庫邏輯完全封裝起來了。一種快速但是笨拙的解決方法是放棄DAO模式,將數(shù)據(jù)庫連接邏輯加到應(yīng)用層中來。這可能對一些小的應(yīng)用程序有效,但是在大的系統(tǒng)中,這是一個嚴(yán)重的設(shè)計(jì)缺陷,妨礙了系統(tǒng)的可擴(kuò)展性。

          在Web層進(jìn)行延遲加載

          幸運(yùn)的是,Spring框架為Hibernate延遲加載與DAO模式的整合提供了一種方便的解決方法。對那些不熟悉Spring與Hibernate集成使用的人,我不會在這里討論過多的細(xì)節(jié),但是我建議你去了解Hibernate與Spring集成的數(shù)據(jù)訪問。以一個Web應(yīng)用為例,Spring提供了OpenSessionInViewFilter和OpenSessionInViewInterceptor。我們可以隨意選擇一個類來實(shí)現(xiàn)相同的功能。兩種方法唯一的不同就在于interceptor在Spring容器中運(yùn)行并被配置在web應(yīng)用的上下文中,而Filter在Spring之前運(yùn)行并被配置在web.xml中。不管用哪個,他們都在請求將當(dāng)前會話與當(dāng)前(數(shù)據(jù)庫)線程綁定時打開Hibernate會話。一旦已綁定到線程,這個打開了的Hibernate會話可以在DAO實(shí)現(xiàn)類中透明地使用。這個會話會為延遲加載數(shù)據(jù)庫中值對象的視圖保持打開狀態(tài)。一旦這個邏輯視圖完成了,Hibernate會話會在Filter的doFilter方法或者Interceptor的postHandle方法中被關(guān)閉。下面是每個組件的配置示例:


          Interceptor的配置:

          <beans>
          <bean id="urlMapping"
          class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
          <property name="interceptors">
          <list>
          <ref bean="openSessionInViewInterceptor"/>
          </list>
          </property>
          <property name="mappings">

          </bean>

          <bean name="openSessionInViewInterceptor"
          class="org.springframework.orm.hibernate.support.OpenSessionInViewInterceptor">
          <property name="sessionFactory"><ref bean="sessionFactory"/></property>
          </bean>
          </beans>

          Filter的配置

          <web-app>

          <filter>
          <filter-name>hibernateFilter</filter-name>
          <filter-class>
          org.springframework.orm.hibernate.support.OpenSessionInViewFilter
          </filter-class>
          </filter>

          <filter-mapping>
          <filter-name>hibernateFilter</filter-name>
          <url-pattern>*. spring </url-pattern>
          </filter-mapping>

          </web-app>


          實(shí)現(xiàn)Hibernate的Dao接口來使用打開的會話是很容易的。事實(shí)上,如果你已經(jīng)使用了Spring框架來實(shí)現(xiàn)你的Hibernate Dao,很可能你不需要改變?nèi)魏螙|西。方便的HibernateTemplate公用組件使訪問數(shù)據(jù)庫變成小菜一碟,而DAO接口只有通過這個組件才可以訪問到數(shù)據(jù)庫。下面是一個示例的DAO:


          public class HibernateProductDAO extends HibernateDaoSupport implements ProductDAO {

          public Product getProduct(Integer productId) {
          return (Product)getHibernateTemplate().load(Product.class, productId);
          }

          public Integer saveProduct(Product product) {
          return (Integer) getHibernateTemplate().save(product);
          }

          public void updateProduct(Product product) {
          getHibernateTemplate().update(product);
          }
          }

          在業(yè)務(wù)邏輯層中使用延遲加載

          即使在視圖外面,Spring框架也通過使用AOP 攔截器 HibernateInterceptor來使得延遲加載變得很容易實(shí)現(xiàn)。這個Hibernate 攔截器透明地將調(diào)用配置在Spring應(yīng)用程序上下文中的業(yè)務(wù)對象中方法的請求攔截下來,在調(diào)用方法之前打開一個Hibernate會話,然后在方法執(zhí)行完之后將會話關(guān)閉。讓我們來看一個簡單的例子,假設(shè)我們有一個接口BussinessObject:


          public     interface    BusinessObject     {
          public     void    doSomethingThatInvolvesDaos();
          }
          類BusinessObjectImpl實(shí)現(xiàn)了BusinessObject接口:

          public     class    BusinessObjectImpl    implements    BusinessObject     {
          public     void    doSomethingThatInvolvesDaos()     {
          //    lots of logic that calls
          //    DAO classes Which access
          //    data objects lazily  
          }  
          }  


          通過在Spring應(yīng)用程序上下文中的一些配置,我們可以讓將調(diào)用BusinessObject的方法攔截下來,再令它的方法支持延遲加載。看看下面的一個程序片段:


          <beans>
          <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate.HibernateInterceptor">
          <property name="sessionFactory">
          <ref bean="sessionFactory"/>
          </property>
          </bean>
          <bean id="businessObjectTarget" class="com.acompany.BusinessObjectImpl">
          <property name="someDAO"><ref bean="someDAO"/></property>
          </bean>
          <bean id="businessObject" class="org.springframework.aop.framework.ProxyFactoryBean">
          <property name="target"><ref bean="businessObjectTarget"/></property>
          <property name="proxyInterfaces">
          <value>com.acompany.BusinessObject</value>
          </property>
          <property name="interceptorNames">
          <list>
          <value>hibernateInterceptor</value>
          </list>
          </property>
          </bean>
          </beans>

          當(dāng)businessObject被調(diào)用的時候,HibernateInterceptor打開一個Hibernate會話,并將調(diào)用請求傳遞給BusinessObjectImpl對象。當(dāng)BusinessObjectImpl執(zhí)行完成后,HibernateInterceptor透明地關(guān)閉了會話。應(yīng)用層的代碼不用了解任何持久層邏輯,還是實(shí)現(xiàn)了延遲加載。


          在單元測試中測試延遲加載

          最后,我們需要用J-Unit來測試我們的延遲加載程序。我們可以輕易地通過重寫TestCase類中的setUp和tearDown方法來實(shí)現(xiàn)這個要求。我比較喜歡用這個方便的抽象類作為我所有測試類的基類。


          public abstract class MyLazyTestCase extends TestCase {

          private SessionFactory sessionFactory;
          private Session session;

          public void setUp() throws Exception {
          super.setUp();
          SessionFactory sessionFactory = (SessionFactory) getBean("sessionFactory");
          session = SessionFactoryUtils.getSession(sessionFactory, true);
          Session s = sessionFactory.openSession();
          TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(s));

          }

          protected Object getBean(String beanName) {
          //Code to get objects from Spring application context
          }

          public void tearDown() throws Exception {
          super.tearDown();
          SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
          Session s = holder.getSession();
          s.flush();
          TransactionSynchronizationManager.unbindResource(sessionFactory);
          SessionFactoryUtils.closeSessionIfNecessary(s, sessionFactory);
          }
          }

           

          Html 屏蔽鼠標(biāo)右鍵

          <body oncontextmenu="self.event.returnValue=false">

          啟動監(jiān)聽 oracle用戶下執(zhí)行

          lsnrctl start

          >192.168.1.242

          現(xiàn)在好了。

          [oracle@localhost ~]$ lsnrctl start

          LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 31-1 -2007 15:12:34

          Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.

          Starting /opt/oracle/9.2.0/bin/tnslsnr: please wait...

          TNSLSNR for Linux: Version 9.2.0.4.0 - Production

          System parameter file is /opt/oracle/9.2.0/network/admin/listener.ora

          Log messages written to /opt/oracle/9.2.0/network/log/listener.log

          Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))

          Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

          Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))

          STATUS of the LISTENER

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

          Alias                     LISTENER

          Version                   TNSLSNR for Linux: Version 9.2.0.4.0 - Production

          Start Date                31-1 -2007 15:12:35

          Uptime                    0 days 0 hr. 0 min. 0 sec

          Trace Level               off

          Security                  OFF

          SNMP                      OFF

          Listener Parameter File   /opt/oracle/9.2.0/network/admin/listener.ora

          Listener Log File         /opt/oracle/9.2.0/network/log/listener.log

          Listening Endpoints Summary...

           (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))

           (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

          Services Summary...

          Service "PLSExtProc" has 1 instance(s).

           Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

          Service "futuredb" has 1 instance(s).

           Instance "futuredb", status UNKNOWN, has 1 handler(s) for this service...

          The command completed successfully

          查看linux正在使用的端口命令   netstat -an

          動態(tài)查看日志文件 tail -f 文件名

          解壓tar文件 tar -xvf 文件名.tar

          打包tar文件 tar -cvf 文件名.tar

          解壓gz文件   gunzip 文件名.gz

          解壓縮gz文件 gzip 文件名

          解壓cpio文件 cpio -idmv < *.cpio

          1、 安全拷貝

          Scp 文件名 IP/目錄

          注意:SSH必須啟動 SSH 端口22

          2、 移動

          Mv 文件名 路徑 將某個文件移動到某個路徑下

          3、 刪除

          Rm –rf /文件名 刪除文件或者文件夾 -rf 命令將不提示徹底刪除

          4、 oracle 狀態(tài)進(jìn)程

          ps –eflgrep ora

          5、 啟動oralce監(jiān)聽

          lsnrctl start

          6、查看oralce監(jiān)聽

          Lsnrctl status

          7、啟動oracle服務(wù)

          進(jìn)入oralce 用戶

          Sqlplus ‘/as sysdba’

          Startup

          Exit

          8、查看所有IP

          Ifconfig –a

          9、查看oracle端口正常不

                 Netstat –an|grep 1521

          10、登錄oracle sqlplus

                 oracle目錄下

                 Sqlplus neme/password@sid_IP

          11、查看命令

                 命令 –help

                 Man 命令

                 Info 命令

          12、查看歷史

                 History |more

                 History 5

          Html 禁止鼠標(biāo)右鍵

          oncontextmenu="self.event.returnValue=false"

          Linux下安裝配置Oralce

          安裝好Oracle 后在Oracle用戶下/home/Oracle目錄下用 vi .bash_profile 命令,在里面配置環(huán)境變量

          # .bash_profile

          # Get the aliases and functions

          if [ -f ~/.bashrc ]; then

                  . ~/.bashrc

          fi

          # User specific environment and startup programs

          PATH=$PATH:$HOME/bin

          export PATH

          export ORACLE_BASE=/backup/oracle

          export ORACLE_HOME=/backup/oracle/product/10.2.0

          export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH

          export ORACLE_OWNER=oracle

          export ORACLE_SID=futureoa

          #export ORACLE_SID

          export ORACLE_TERM=xterm

          #export ORACLE_TERM

          export LD_ASSUME_KERNEL=2.6.9

          #export THREADS_FLAG=native

          LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

          LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

          export LD_LIBRARY_PATH

          export PATH=$PATH:$ORACLE_HOME/bin

          export NLS_LANG=AMERICAN_AMERICA.UTF8

          #export LANG=en_US

          export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data

          CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

          CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib

          export CLASSPATH

          unset USERNAME

          # Oracle Settings

          # Oracle Settings

          ~

          ".bash_profile" 36L, 954C       

          在啟動WebSphere應(yīng)用服務(wù)器的時候報告端口沖突
          最常見的情況是已有一個應(yīng)用服務(wù)器實(shí)例在運(yùn)行了。這樣的話,要么只啟動一個實(shí)例,要么更改一個實(shí)例的端口號。還有一個常見的問題是在AIX 5L環(huán)境上報9090端口沖突。其原因是在AIX 5L中缺省會有一個wsmservr啟動,并占用9090端口。因此在啟動或安裝WebSphere應(yīng)用服務(wù)器前,要確認(rèn)系統(tǒng)wsmserver沒有啟動。如果這個服務(wù)已經(jīng)啟動,我們用下面命令停止wsmserver服務(wù):/usr/websm/bin/wsmserver -disable。如果說需要保留這個占用9090端口的服務(wù),那么我們只能通過更改應(yīng)用服務(wù)器的管理控制臺應(yīng)用的端口。由于控制臺本身的端口被占用了,因此我們不能通過控制臺來操作,而只能直接修改配置文件。這里我們要修改兩個文件。一個是virtualhosts.xml文件,它的路徑為WebSphere應(yīng)用服務(wù)器安裝目錄/config/cells/單元名/。把其中的9090端口改成沒有沖突的端口,比如9091。另一個要更改的文件是server.xml,它的路徑為WebSphere應(yīng)用服務(wù)器安裝目錄/config/cells/單元名/nodes/節(jié)點(diǎn)名/servers/server1。同樣把其中的9090端口更改成9091。注意兩個文件的更改需要一致。

          使用命令建立“概要文件管理工具”中的“應(yīng)用服務(wù)器”即單元節(jié)點(diǎn)

          命令D:"Java"IBM"WebSphere"AppServer"bin"ProfileManagement>pmt.bat可以打開建立“概要文件管理工具”的窗口

          Windows下刪除Websphere的服務(wù)

          在注冊表中 運(yùn)行-regedit

          HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services

          HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services

          HKEY_LOCAL_MACHINE/SYSTEM/ControlSet003/Services

          下面找到IBMWAS61Service - DBF01A8E0E0F455Node03

          Websphere的服務(wù)刪除就可以了

          >啟動Oracle的命令是啥丫

          啟動監(jiān)聽: lsnrctl start

          sqlplus '/as sysdba'

          startup

           

           

           

           

          動態(tài)瀏覽vi 內(nèi)容

          tail -f filename.txt

          linux 時間

          顯示當(dāng)前時間

          date

          設(shè)置時間

          date -s "2007-6-25 15:14:00"

          clock -w

          WebSphere 日志跟蹤${SERVER_LOG_ROOT}/SystemOut.log

          linux下設(shè)置ldap隨系統(tǒng)自動啟動

          在終端命令行輸入

          Ntsysv

          在出現(xiàn)對界面中選中ldap就可以了

          posted on 2007-11-12 09:43 禮物 閱讀(1748) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。

          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 岳普湖县| 博乐市| 泗阳县| 明溪县| 勃利县| 琼中| 开鲁县| 山丹县| 栾川县| 宽甸| 瑞昌市| 济南市| 嘉祥县| 武鸣县| 南充市| 横峰县| 永新县| 河池市| 上栗县| 方山县| 长治县| 正宁县| 平阴县| 运城市| 忻城县| 通榆县| 塔城市| 盱眙县| 三原县| 龙井市| 荔浦县| 库尔勒市| 胶州市| 南充市| 雷波县| 尚义县| 聊城市| 梅州市| 和田市| 甘孜县| 高雄县|