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 阅读(395) | 评论 (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 阅读(221) | 评论 (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 阅读(189) | 评论 (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 阅读(355) | 评论 (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 阅读(377) | 评论 (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 阅读(257) | 评论 (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 阅读(327) | 评论 (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 阅读(280) | 评论 (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 阅读(760) | 评论 (0)编辑 收藏
physical disk, physical memory

a time-consuming operation

并,共,多
concurrent
shared
simultaneous
synchronize
multiprocess
distributed processing
posted @ 2006-07-15 21:52 Jcat 阅读(272) | 评论 (0)编辑 收藏
仅列出标题
共17页: First 上一页 9 10 11 12 13 14 15 16 17 下一页