waterye

          #

          鎖管理

          查看鎖
          select t2.username,t2.sid,t2.serial#,t2.logon_time 
            
          from v$locked_object t1,v$session t2 
           
          where t1.session_id=t2.sid order by t2.logon_time;

          kill 鎖
          alter system kill session 'sid,serail#';
          也可以用oem來殺掉

          posted @ 2005-09-07 00:55 waterye 閱讀(303) | 評論 (0)編輯 收藏

          升級播放程序

          為了播放不同編碼的視頻文件, 真的好煩, 裝了一堆播放器, 有的還不兼容, 千萬不要用不負責任ffdshow。

          RealPlayer+K-Lite Code Pack(2.5.3)+WinDvd(7.0 Platinum),KMplayer當備用


          現在順心多了, 但還有點小問題, WinDvd(占用cpu很少)播放小部分vob還是會出錯, 用realplayer代勞算了。

          posted @ 2005-09-07 00:51 waterye 閱讀(607) | 評論 (2)編輯 收藏

          GvTags

          GvTags makes it easy to write web applications in the new dynamic programming language Groovy. GvTags is a Groovy Tag library for Java ServerPages (JSP). GvTags might be for the Groovy programming language what the combination of JSTL and Struts is for Java, or Smarty is for PHP.

          官方站點: http://gvtags.berlios.de/cgi-bin/gvtagswiki.pl

          最新版本是0.1.1

          下載了源碼包看了一下, 還是挺有意思的.

          <gv:import class='org.gvtags.examples.counter.Counter' />
          <gv:bean var='c' class='Counter' scope='session' />
          <gv:formbean var='formBean' />
          <gv:code>
              if (formBean.submit != null) {
                  // handle input
                  switch(formBean.submit.trim()) {
                      case "+":
                          c.increment()
                          break
                      case "-":
                          c.decrement()
                          break
                      case "Reset":
                          c.reset()
                          break
                  }
              }
          </gv:code>

          大部分源碼是groovy寫的

          posted @ 2005-09-05 18:45 waterye 閱讀(615) | 評論 (1)編輯 收藏

          pl/sql script

          將select出來的數據update到其他table, 使用JDBC的話幾行代碼就搞定, 但要經過不算煩人的compile, 為了在沒有Java的環境使用(安裝新版本的Oracle要JVM)

          用pl/sql script是更簡單方法,從在線文檔copy個sample過來, 改一改就能用

          DECLARE
              
          CURSOR c1 IS SELECT order_item_no, unit_price FROM sale_order_item;
              TYPE ResultSet 
          IS TABLE OF c1%ROWTYPE;
              rs ResultSet; 
          BEGIN
              
              
          select i.order_item_no, goods.unit_price BULK COLLECT into rs
            
          from sale_order o, sale_order_item i, goods
           
          where o.order_no = i.order_no
             
          and i.goods_no = goods.goods_no
             
          and trunc(o.order_time, 'month'>= to_date('2005-6''yyyy-mm');

              
          IF rs.count > 0 THEN 
                  
          FOR i IN rs.FIRST .. rs.LAST LOOP
                      
          update sale_order_item set unit_price = rs(i).unit_price where order_item_no = rs(i).order_item_no;
                  
          END LOOP; 
              
          END IF;
              
              
          commit;
                  
          END;

          再在sqlplus運行
          sqlplus /nolog
          conn 
          user/passoword@sid
          @update.sql

          posted @ 2005-09-03 16:26 waterye 閱讀(406) | 評論 (0)編輯 收藏

          Groovy String

          1. 單行String
          單引號是普通字符串, 雙引號是GString
          def hw = 'hello, world'
          println 
          'hello, world'
          println 
          'groovy say "Hello, world!"'
          println 
          "groovy say ${hw}"

          2. 多行String
          def blogAddr = 'http://www.aygfsteel.com/waterye'
          println 
          """\
          Water Ye's blog:
          ${blogAddr}
          """

          3. 使用range獲取substring
          println hw[hw.length()-1..0]
          不用羨慕python,ruby了

          4. 增加的api, 參考gdk
          http://groovy.codehaus.org/groovy-jdk.html

          posted @ 2005-09-03 15:55 waterye 閱讀(3196) | 評論 (0)編輯 收藏

          Hibernate的視圖功能

          Hibernate3增加了視圖功能

          1. 定義hbm
              <class name="Customer" table="customer">        
                  
          <id name="id" unsaved-value="0" column="id">
                      
          <generator class="hilo"/>
                  
          </id>        
                  
          <property name="name"  not-null="true"/>        
              
          </class>
              
              
          <class name="Supplier" table="supplier">        
                  
          <id name="id" unsaved-value="0" column="id">
                      
          <generator class="hilo"/>
                  
          </id>
                  
          <property name="name" not-null="true"/>            
              
          </class>
              
              
          <class name="All" mutable="false">    
                  
          <subselect>
                      select id, name from customer
                      union 
                      select id, name from supplier
                  
          </subselect>
                  
                  
          <synchronize table="customer"/>
                  
          <synchronize table="supplier"/>
                  
                  
          <id name="id" unsaved-value="0" column="id">
                      
          <generator class="hilo"/>
                  
          </id>        
                  
          <property name="name"/>        
              
          </class>

          2. 定義POJO
          pulic class Customer {
              
          public Integer id;
              
          public String name;
          }


          pulic 
          class Supplier {
              
          public Integer id;
              
          public String name;
          }


          pulic 
          class All {
              
          public Integer id;
              
          public String name;
          }

          3. 查詢
          List all = session.createQuery("from All").list();

          posted @ 2005-09-02 22:39 waterye 閱讀(5875) | 評論 (2)編輯 收藏

          復制表

          復制表結構和數據
          create table new_table as select * from old_table;

          復制表結構
          create table new_table as select * from old_table where 1=0;

          posted @ 2005-09-02 21:58 waterye 閱讀(367) | 評論 (0)編輯 收藏

          通過RowId刪除重復記錄

          通過RowId刪除重復記錄

          DELETE FROM test t1
           
          WHERE t1.ROWID <
                 (
          SELECT max(t2.ROWID) FROM test t2 WHERE t2.name = t1.name);

          posted @ 2005-09-01 20:54 waterye 閱讀(384) | 評論 (0)編輯 收藏

          Spring book

          隨著Spring的流行, 書還真出了不少

          本人收集的有:
          1. <<Spring Live>>
          2. <<Spring In Action>>
          3. <<Pro Spring>>
          4. <<Spring A Developers Notebook>>
          5. <<Professional Java Development with the Spring Framework>>

          看了第5本(Core Developer寫的)的話, 就不用看其他的了, 有的簡直是騙錢,還不如看petclinic

          posted @ 2005-08-31 21:20 waterye 閱讀(2762) | 評論 (12)編輯 收藏

          Hibernate的查詢方式

          小結Hibernate的查詢方式

          1. get() and load()
          session.get(Clazz, id);
          session.load(Clazz, id);

          說明: load()與get()的區別
          請注意如果沒有匹配的數據庫記錄,load()方法可能拋出無法恢復的異常(unrecoverable exception)。 如果類的映射使用了代理(proxy),load()方法會返回一個未初始化的代理,直到你調用該代理的某方法時才會去訪問數據庫。 若你希望在某對象中創建一個指向另一個對象的關聯,又不想在從數據庫中裝載該對象時同時裝載相關聯的那個對象,那么這種操作方式就用得上的了。 如果為相應類映射關系設置了batch-size, 那么使用這種操作方式允許多個對象被一批裝載(因為返回的是代理,無需從數據庫中抓取所有對象的數據)。

          如果你不確定是否有匹配的行存在,應該使用get()方法,它會立刻訪問數據庫,如果沒有對應的行,會返回null

          2. HQL

          // 返回一行記錄
          String hql = "from TOrder o where o.id = ?";
          TOrder o 
          = (TOrder) s.createQuery(hql)
                  .setParameter(
          0, orderId)
                  .uniqueResult();

          // 命名參數
          Query q = sess.createQuery("from DomesticCat cat where cat.name = :name");
          q.setString(
          "name""Fritz");

          // 位置參數
          Query q = sess.createQuery("from DomesticCat cat where cat.name = ?");
          q.setString(
          0"Izi");

          // 命名參數列表
          Query q = sess.createQuery("from DomesticCat cat where cat.name in (:namesList)");
          q.setParameterList(
          "namesList", names);

          // 分頁查詢 
          Query q = sess.createQuery("from DomesticCat cat");
          q.setFirstResult(
          20);
          q.setMaxResults(
          10);
          List cats 
          = q.list();


          3. Criteria

          List list = s.createCriteria(Enrolment.class)
                      .createAlias(
          "student""s")
                      .createAlias(
          "course""c")
                      .add( Restrictions.isNotEmpty(
          "s.enrolments") )
                      .setProjection( Projections.projectionList()
                              .add( Projections.property(
          "s.name") )
                              .add( Projections.property(
          "c.description") )
                      )
                      .setCacheable(
          true)
                      .list();


          4. Native SQL

          String treeSql = "" +
                          
          "select {t.*}, level from tree t " +
                          
          " start with t.parent_id = 0 " +
                          
          " connect by prior t.id = t.parent_id";

          List result 
          = session.createSQLQuery(treeSql)
              .addEntity(
          "t", Tree.class)
              .addScalar(
          "level", Hibernate.INTEGER)
              .list();

          5. Named SQL queries(不推薦)

          6. filter(不推薦)

          7. Detached queries(還沒測試)
          The DetachedCriteria class lets you create a query outside the scope of a session, and then later execute it using some arbitrary Session

          參考
          1. Hibernate Reference Documentation
          2. Hibernate test case

          posted @ 2005-08-29 16:34 waterye 閱讀(4130) | 評論 (3)編輯 收藏

          僅列出標題
          共18頁: First 上一頁 10 11 12 13 14 15 16 17 18 下一頁 
          主站蜘蛛池模板: 焦作市| 双流县| 肃北| 中超| 涞水县| 江达县| 平湖市| 丰都县| 迁安市| 嫩江县| 平南县| 甘洛县| 礼泉县| 江津市| 宝兴县| 宁南县| 钟祥市| 许昌市| 开原市| 扎兰屯市| 和顺县| 黄浦区| 盱眙县| 广平县| 浦北县| 昆山市| 牙克石市| 阆中市| 安泽县| 福海县| 扬州市| 荔浦县| 保德县| 长汀县| 察隅县| 安康市| 杭锦旗| 铜山县| 山东省| 平原县| 常德市|