Jcat
          寵辱不驚,閑看庭前花開花落~~
          posts - 173,comments - 67,trackbacks - 0

          如果查詢中包括聚合函數,而所選擇的列并不在聚合函數中, 那么這些列就必須在GROUP BY子句中。否則將會出現如下錯誤:ORA-00937: not a single-group group function


          不能在WHERE子句中使用聚合函數來限制行。否則將會出現如下錯誤:ORA-00934: group function is not allowed here


          GROUP BY可以不與HAVING一起使用,但HAVING必須與GROUP BY一起使用


          W-G-H的執行順序
          SELECT?type_id,?AVG(price)
          FROM?products
          WHERE?price<15
          GROUP?BY?type_id
          HAVING?AVG(price)>13;
          1. WHERE對返回的進行過濾
          2. GROUP BY對保留的行進行分組
          3. HAVING對分組進行過濾


          子查詢不能包含ORDER BY


          雙引號直接用:'The "Great" Gatsby' (表示字符串 The "Great" Gatsby )
          單引號要轉義:'O''Malley' (表示字符串 O'Malley )

          ?DML
          select column1,column2 from table
          insert into table(column1,column2) values('a','b')
          update table set column1='a' where column2='b'
          delete from table where column1='a'


          --外連接,使用叉積表達有歧義,不運行:查詢中包含不允許的外聯接請求。
          select * from a,b,c
          ??????? where a.a_id*=b.a_id
          ??????????? and b.b_id*=c.b_id

          --這樣就不存在歧義性了
          select * from a
          ??? LEFT OUTER JOIN b on (a.a_id=b.a_id)
          ??? LEFT OUTER JOIN c on (b.b_id=c.b_id)

          posted @ 2006-08-23 08:36 Jcat 閱讀(412) | 評論 (1)編輯 收藏

          Pseudo columns

          A pseudo column is an item of data which does not belong in any particular table but which can be treated as if it did. Any SELECT list of columns can include these pseudo columns.
          SYSDATE         current date and time
          
          ROWNUM          sequence number assigned to retrieved rows
          
          ROWID           unique identifier for a row
          
          UID             number associated with a user
          
          USER            userid of current user
          

          The DUAL table

          ORACLE provides a "dummy" table called DUAL containing one column and one row. It is useful for selecting miscellaneous information from ORACLE.

          Some uses for DUAL

          • Display today's date

            SELECT SYSDATE FROM dual;

          • Display the value of 356 divided by 17, to three decimal places

            SELECT ROUND(356 / 17, 3) FROM dual;

          • Display the current user name

            SELECT USER FROM dual;

          posted @ 2006-08-18 08:50 Jcat 閱讀(238) | 評論 (0)編輯 收藏

          http://www.oracle.com/pls/db102/portal.portal_db?selected=3#index-SQL

          Basical
          ?
          Concepts -> Administrator's Guide -> SQL Reference


          Advanced?

          PL/SQL User's Guide and Reference

          SQL*Plus User's Guide and Reference

          Reference

          Application Developer's Guide – Fundamentals

          Backup and Recovery Advanced User's Guide

          Backup and Recovery Basics

          Backup and Recovery Reference

          ?

          posted @ 2006-08-12 17:03 Jcat 閱讀(198) | 評論 (0)編輯 收藏
          吉祥三寶

          http://struts.apache.org/


          http://www.springframework.org/


          http://www.hibernate.org/

          Apache

          http://ant.apache.org/
          Apache Ant is a Java-based build tool. In theory, it is kind of like Make, but without Make's wrinkles.

          http://lucene.apache.org/

          Apache Lucene is a high-performance, full-featured text search engine library written entirely in Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform.

          http://jakarta.apache.org/commons/index.html
          The Commons is a Jakarta subproject focused on all aspects of reusable Java components.

          http://jakarta.apache.org/velocity/index.html
          Velocity is a Java-based template engine. It permits anyone to use a simple yet powerful template language to reference objects defined in Java code.

          Sourceforge

          http://junit.sourceforge.net/
          JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.

          http://httpunit.sourceforge.net/
          HttpUnit makes you easy? to be able to bypass the browser and access your site from a program. When combined with a framework such as JUnit, it is fairly easy to write tests that very quickly verify the functioning of a web site.

          http://dozer.sourceforge.net/
          Dozer is a powerful, yet simple Java Bean to Java Bean mapper that recursively copies data from one object to another. Typically, these Java Beans will be of different complex types.

          http://xdoclet.sourceforge.net/xdoclet/index.html
          XDoclet is an open source code generation engine. It enables Attribute-Oriented Programming for java. In short, this means that you can add more significance to your code by adding meta data (attributes) to your java sources. This is done in special JavaDoc tags.

          http://displaytag.sourceforge.net
          The display tag library is an open source suite of custom tags that provide high-level web presentation patterns which will work in an MVC model. Actually the display tag library can just... display tables! Give it a list of objects and it will handle column display, sorting, paging, cropping, grouping, exporting, smart linking and decoration of a table in a customizable XHTML style.

          http://cglib.sourceforge.net/
          cglib is a powerful, high performance and quality Code Generation Library, It is used to extend JAVA classes and implements interfaces at runtime.

          Others

          http://www.opensymphony.com/compass/
          Compass is a first class open source Java Search Engine Framework, enabling the power of Search Engine semantics to your application stack decoratively. Built on top of the amazing Lucene Search Engine, Compass integrates seamlessly to popular development frameworks like Hibernate and Spring.

          http://www.opensymphony.com/quartz/
          Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application - from the smallest stand-alone application to the largest e-commerce system.

          http://groovy.codehaus.org/
          Groovy is an agile dynamic language for?the Java Platform with many features that are inspired by languages like Python, Ruby and Smalltalk, making them available to Java developers using a Java-like syntax.

          http://www.singularsys.com/jep/
          JEP
          is a Java library for parsing and evaluating mathematical expressions. With this package you can allow your users to enter an arbitrary formula as a string, and instantly evaluate it. JEP supports user defined variables, constants, and functions. A number of common mathematical functions and constants are included.

          http://www.dom4j.org/
          dom4j is an easy to use, open source library for working with XML, XPath and XSLT on the Java platform using the Java Collections Framework and with full support for DOM, SAX and JAXP.

          http://www.castor.org/
          Castor is an Open Source data binding framework for Java. It's the shortest path between Java objects, XML documents and relational tables. Castor provides Java-to-XML binding, Java-to-SQL persistence, and more.
          posted @ 2006-08-12 15:28 Jcat 閱讀(375) | 評論 (0)編輯 收藏
          單行注釋: ##your note
          多行注釋: #*your note*#

          不能直接訪問對象的域,只能通過方法來訪問。關于方法的調用,有兩種變體(Velocity會幫你調用相應的方法):
          1)對于context中的Hashtable對象,可以直接用$hashtable.key來得到value,相當于$hashtable.get(key)
          2)對于context中的JavaBean對象,可以直接用$javaBean.property來訪問,相當于$javaBean.getProperty()

          安靜引用符(Quiet Reference Notation)$!
          作用:當引用的變量為null時,將輸出空字符串。(如果用$xxx,當null時,會輸出字符串"$xxx")

          雙引號中的$xxx將仍然被解析;單引號中的$xxx將不被解析,輸出字符串"$xxx"

          關于路徑:
          1. 為VelocityEngine指定velocityLoaderPath,該路徑為存放vm文件的根目錄(其下可以建子文件夾,無需另外指定)
          2. 對vm的引用都是以velocityLoaderPath開始的絕對路徑。比如:
          ?|-velocityLoaderPath
          ???|-a.vm
          ???|-B
          ?????|-b.vm
          在b.vm中引用a.vm:#parse("a.vm") 正確;? #parse("../a.vm") 錯誤
          posted @ 2006-08-08 08:21 Jcat 閱讀(394) | 評論 (0)編輯 收藏

          最后的逗號
          String[] strs = {"1", "2", "3", };
          System.out.println(strs.length); //3

          這竟然是符合語法的!

          ArrayInitializer:???????
          { [VariableInitializer {, VariableInitializer} [,]] }
          VariableInitializer:?ArrayInitializer?Expression
          http://java.sun.com/docs/books/jls/third_edition/html/syntax.html#18.1

          "This is good for quick testing. I always use this. In my case, I have a table, sometimes I care some columns, other times I care some other columns, so I am lazy to remove the last comma when I change columns. It's convenient."



          運行沒有main的java類
          ??????通常我們需要在java類中添加main函數才能在命令行運行這個類,但是有一種(可以讓你暈死的)方法可以讓你在沒有main的情況下也可以運行java class(當然不是用applet),代碼如下:

          public ? class ?NoMainMethod
          {
          ????
          static
          {
          ????????System.out.println(
          " Hello?word,?no?main?method! " );
          ????????System.exit(
          0 );
          ????}

          }

          ??????static語句塊會在加載類的時候加載,它在main函數之前運行。 當static語句塊運行完畢后,會尋找main函數,如果沒有找到,就會拋出異常。但是在以上的代碼中,static語句塊執行后,我們終止程序的運行,所以異常就不會被拋出啦。


          跳出JavaBean的命名規范
          ??????通常,JavaBean的命名規范為:屬性名的第二個字母也不能大寫。即不可以出現類似 aAndB 這樣的屬性名。如,Hibernate的PO如果出現這樣的名字,將拋出net.sf.hibernate.PropertyNotFoundException異常。但是有一個辦法可以解決該問題:

          java?file:?????
          private ?String?aAndB;???
          public ?String?getAAndB()? {????????
          ????????
          return ?aAndB;???
          }
          ???
          public ? void ?setAAndB(String?aAndB)? {???????
          ???????? this .aAndB? = ?aAndB;???
          }

          mapping.xml < property? name ="AAndB" ?column ="a_and_b" />
          ??????結研究發現,上述辦法可以成功的將aAndB這樣的屬性與數據庫mapping起來。
          ??????顯然hibernate是通過setter和getter來訪問對象的屬性的,所以我們可以說:mapping.xml并不是在類的屬性和數據庫的字段名之間做映射,而是在setter/getter和數據庫的字段之間做映射。
          ??????誠然,即使可以也別這么干,實際工作中,還是規避這種問題的好。?

          posted @ 2006-08-06 00:27 Jcat 閱讀(278) | 評論 (0)編輯 收藏
          Experience
          To know how dose List.remove(Object) work, I do many test sample. But I still feel not very realizing. Finally, I?took a look at?souce code, and then I knew everything!
          public?boolean?remove(Object?o)?{
          ????
          if?(o?==?null)?{
          ????????????
          for?(int?index?=?0;?index?<?size;?index++)
          ????????
          if?(elementData[index]?==?null)?{
          ????????????fastRemove(index);
          ????????????
          return?true;
          ????????}

          ????}
          ?else?{
          ????????
          for?(int?index?=?0;?index?<?size;?index++)
          ????????
          if?(o.equals(elementData[index]))?{
          ????????????fastRemove(index);
          ????????????
          return?true;
          ????????}

          ????????}

          ????
          return?false;
          ????}
          1. List store very object's reference but object's own.
          2. remove(Object) will remove the first reference in List which refer to?the object
          3. If you want to change an object to a new index: back up it--> remove it--> re-add it

          Experience
          I create a class to handle something annotated by Annotations. But it doesn't work. I found out it is returned false by Class.getMethod().isAnnotationPresent(Todo.class). Finally, I got the reason by reading source code.
          public?enum?RetentionPolicy?{
          ????
          /**
          ?????*?Annotations?are?to?be?discarded?by?the?compiler.
          ?????
          */
          ????SOURCE,

          ????
          /**
          ?????*?Annotations?are?to?be?recorded?in?the?class?file?by?the?compiler
          ?????*?but?need?not?be?retained?by?the?VM?at?run?time.??This?is?the?default
          ?????*?behavior.
          ?????
          */
          ????CLASS,

          ????
          /**
          ?????*?Annotations?are?to?be?recorded?in?the?class?file?by?the?compiler?and
          ?????*?retained?by?the?VM?at?run?time,?so?they?may?be?read?reflectively.
          ?????*
          ?????*?
          @see?java.lang.reflect.AnnotatedElement
          ?????
          */
          ????RUNTIME
          }

          posted @ 2006-08-03 18:43 Jcat 閱讀(348) | 評論 (0)編輯 收藏

          Languages

          Java: SCJP1.5 (Just for interesting, waiting for a good book about 1.5)

          English: Java is our father, while English is our mother!

          XML: XML schema vs DTD

          SQL: PL/SQL

          UML

          HTML + JS + CSS (Just a little)

          Java Frame Work

          Junit vs TestNG

          Ant

          Struts + Spring + Hibernate

          Lucene + Compass
          ?

          Tools

          IntelliJ: Keymap practice and Plugin investigation

          Oracle 10g: To be a OCA at first

          PowerDesigner

          Tomcat vs ???

          Postgre

          Linux: Very important, but I?have no any other time in faith.


          Others

          7habits: To be a habit, but time is also a big problem

          Design Pattern: To read gof's book.

          AJAX

          AOP

          J2ME

          posted @ 2006-07-31 22:44 Jcat 閱讀(306) | 評論 (0)編輯 收藏
          狀:剛配置好struts,可是DispatchAction怎么都不工作(Action可以工作),也不報錯
          原因:只引入了struts自身的jar,看一看release中lib下,還有不少非struts的jar,可以猜想這些都是DispatchAction所需要的,而Action不需要(以前以為這些沒用)。不報錯讓我很郁悶。



          狀:剛配置好struts,action可以工作了,就是不能正確的forward到jsp頁面,execute中加斷點,也不進入。
          原因:execute有兩個!!!HttpServletRequest vs ServletRequest,前者才是struts所使用的execute。



          狀:在web.xml里面設置好了

          <error-page>
          ????????
          <error-code>404</error-code>
          ????????
          <location>/404.jsp</location>
          </error-page>

          但當出現404錯誤時,并沒有顯示404.jsp這一頁,而是顯示browser提供的error report page

          原因:在客戶端瀏覽器如IE的internet選項高級屬性中默認使用“友好的http錯誤信息”,這樣會造成你的服務器是輸出你所定義的錯誤頁面,但到客戶端被IE這混蛋給覆蓋掉了。解決方案是你定義的錯誤頁面的大小必須大于512bytes,就不會被客戶端設置所影響了。



          狀:用hibernate訪問數據庫,可以insert,可以select,可以drop,就是不能update,而且沒有任何錯誤消息

          原因:
          <class name="com.verican.base.model.CatalogPO" table="sys_catalog" mutable="false">設置成true即可。
          (當mutable=false,卻又執行update操作時,hibernate至少應該提供警告消息告知一下才對,可惜沒有,所以很難發現)



          狀:
          ??????Javascript彈出窗口時,如果用的是相對路徑,形如javascript:void(window.open('../../test.html')),不同的瀏覽器的處理不同(因為js是瀏覽器處理的東西)。
          ??????比如,不是部署在根目錄下時(根目錄下又建了一個目錄):在Firefox下,是以服務器為視角,則../../即可;而在IE下,則是以瀏覽器為視角,則需要多加一級,如../../../
          ????????????
          解決:用絕對路徑 javascript:void(window.open('http://www.verican.com/test.html'));或者,用 <a target="_blank" href="../../test.html"> (因為這是服務器處理的東西,所以不管部署在哪里,相對路徑都是唯一確定的)



          狀:
          刷新的時候 1)拋出ServletException
          ?????????????????????2)The page cannot be refreshed without resending the information, Click Retry to send the information again.

          原因:Struts中redirect設置問題(具體原理以后再研究)

          解決:一般的,forward到一個具體的page,redirect=false;forward到另一個action,redirect=true
          ???????????
          <forward?name="add_item"?path="newsletter.add_item.page"?redirect="false"/>
          <forward?name="success"?path="/newsletter.do"?redirect="true"/>


          狀:

          save a form --> forward to list page --> refresh --> retry --> save the form again (error)


          原因:
          <forward?name="list"?path="ticket.list.page"?redirect="false"/>

          解決:一般的,從save一個表單后,應該forward到另一個action,且redirect=true(而不是另一個page,即便當前action里有這個page)。這樣可以保證不會通過刷新重復save數據。
          <forward?name="list"?path="ticket.do"?redirect="true"/>



          狀:
          ??????用Spring + Velocity發email,開始都好好的,也能現實圖片,但當加入某一幅圖片以后,無法正常顯示(得到一個頁面為空白的Email,雖然也有大小)。把圖片從bmp換到jpg,再換到gif,未果。減小圖片的尺寸、大小,未果。幾乎都要絕望了~~~

          原因:NOTE: Invoke addInline after setText; else, mail readers might not be able to resolve inline references correctly.(這是Spring API里的原話,NND)

          感受:
          ??????1.以前沒寫過發Email的程序,工作中用到了,照貓畫虎拿過來就用,也沒有仔細閱讀文檔,導致這次慘痛的教訓。
          ????? 2.Spring中這部分設計的也有問題,它在兩個表面上沒什么關系的方法之間,建立了順序上的依賴關系。這使得出現這種情況時,沒有任何線索。



          狀:
          遍歷List時,一調用remove就出錯,(錯誤的)代碼如下
          for?(Object?o?:?list)
          ????
          {
          ????????????list.remove(o);
          ????????}

          原因:ConcurrentModificationException,有remove操作時,不能用foreach循環

          解決:用傳統循環(看了傳統還是很有用的)
          for?(int?i?=?0;?i?<?list.size();?i++)
          ????
          {
          ????????????list.remove(i
          --);
          ????????}
          注意remove過需要 i--? (--i is wrong)



          狀:
          boolean?b?=?new?Integer(3)?==?new?Integer(3);?//false

          原因:其實是很簡單的問題,但是IDEA只會對String的 = = 做智能提示,注意即可。



          狀:
          org.hibernate.MappingException: Could not read mappings from resource: jcat/learn/mapping.xml
          ?
          開始以為路徑沒寫對,試驗了N中路徑的寫發后,還是不行。后來才發現是因為mapping.xml是空的。
          ?
          解決:給mapping.xml加上一個空殼就可以了(好歹空殼不等于空)
          ?
          <?xml?version="1.0"?encoding="gb2312"?>
          <!DOCTYPE?hibernate-mapping?SYSTEM?"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"?>

          <hibernate-mapping?default-lazy="false">

          </hibernate-mapping>
          ?
          NOTE:幾種路徑的寫法
          1. classpath:packagename/filename
          例子:在applicationContext.xml中注冊hibernate.cfg.xml
          <bean?id="GlobalHibernateSessionFactory"?class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
          ????????
          <property?name="dataSource">
          ????????????
          <ref?local="GlobalDataSource"/>
          ????????
          </property>
          ????????
          <property?name="configLocation">
          ????????????
          <value>classpath:hibernate.cfg.xml</value>
          ????????
          </property>
          </bean>

          2. packagename/filename
          例子:在hibernate.cfg.xml中注冊mapping.xml
          <mapping?resource="jcat/learn/hibernate_in_spring/orm.xml"/>


          狀:提交表單程序,加入了上傳文件的功能后,出現異常
          java.lang.IllegalArgumentException: Cannot invoke com.verican.newsadmin.form.TicketForm.setUploadFile - argument type mismatch

          解決:將表單聲明為mulptipart類型
          <html:form?action="/ticket"?enctype="multipart/form-data">
          ?????????
          <html:file?property="uploadFile"/>
          </html:form>



          狀:IE cannot open the Internet site file: ....
          <html>
          <head>
          ????
          <title></title>
          </head>
          <body>
          ????
          <span?id="TypeDes2"/>
          ????
          <script?type="text/javascript">
          ???????TypeDes2.innerHTML?
          =?"Test?Span";
          ????
          </script>
          </body>
          </html>

          解決:對于單標簽,瀏覽器找不到innerHTML屬性。改為雙標簽即可。
          <span?id="TypeDes2"></span>
          posted @ 2006-07-25 13:11 Jcat 閱讀(775) | 評論 (0)編輯 收藏
          physical disk, physical memory

          a?time-consuming operation

          并,共,多
          concurrent
          shared
          simultaneous
          synchronize
          multiprocess
          distributed processing
          posted @ 2006-07-15 21:52 Jcat 閱讀(296) | 評論 (0)編輯 收藏
          僅列出標題
          共17頁: First 上一頁 9 10 11 12 13 14 15 16 17 下一頁 
          主站蜘蛛池模板: 东乌珠穆沁旗| 楚雄市| 曲麻莱县| 淮北市| 五常市| 健康| 开鲁县| 广河县| 陈巴尔虎旗| 仲巴县| 彩票| 中卫市| 临江市| 阳城县| 承德市| 金华市| 新野县| 吉安县| 柏乡县| 阿克陶县| 金坛市| 阿鲁科尔沁旗| 十堰市| 潜江市| 玉环县| 凉山| 靖西县| 南京市| 荔波县| 莆田市| 武山县| 隆德县| 东宁县| 瑞丽市| 蓬莱市| 衡南县| 洱源县| 云龙县| 兴隆县| 新巴尔虎左旗| 合阳县|