<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    The follow statement execute error using 9i driver(Oracle JDBC Driver version - 9.0.2.0.0).
    throw UncategorizedSQLException(Invalid Column Type Exception), 
    errorcode: 17004.
    Upgrade to Oracle JDBC Driver version - 10.2.0.1.0, it is OK.

    Example:

    ......
    PreparedStatement pst = cn.prepareStatement("select sysdate from dual where 1=?");
    pst.setNull(index,  java.sql.Types.NULL);   -------- throw exception!!
    ......




    posted @ 2007-10-09 19:39 bluoy 閱讀(908) | 評論 (0)編輯 收藏

    Using the JDBC 8i, 9iR1, Oracle's DATE datatype is mapped to the "java.sql.Timestamp" class. However, the new "ojdbc14.jar" driver maps DATE to "java.sql.Date", and "java.sql.Date" only holds a date (without a time), whereas "java.sql.Timestamp" holds both a date and a time.




    Subject: JDBC 920x Date/TimeStamp mapping
    Type: BULLETIN
    Status: UNDER_EDIT
    Content Type: TEXT/PLAIN
    Creation Date: 29-JUL-2003
    Last Revision Date: 04-OCT-2004


    PURPOSE
    -------
       Clarify the use of oracle.jdbc.V8Compatible property flag
     
    SCOPE & APPLICATION
    -------------------
    JDBC 920x Date/TimeStamp mapping is different from JDBC 8i, 9iR1.
    <TITLE FOR MAIN ARTICLE TEXT>
    -----------------------------
    Summary of  features afftected by oracle.jdbc.V8Compatible.
     
    As of 9.2.0.1.0 Oracle realigned its DATE type with the java.sql.Types.DATE type.
    Prior to this
    java.sql.DATE and  java.sql.TIMESTAMP were mapped to java.sql.Types.TIMESTAMP.
     
    This mapping change applies to JDBC default mapping (i.e when getObject() is
    used for Date column.
     
    example:
    select sysdate from dual;
    ...
    while (rset.next ())  {
    System.out.println("getObject for sysdate  : " +
    rset.getObject(1).getClass().getName());
    System.out.println("getDate for sysdate :" +
    rset.getDate(1).getClass().getName());
    System.out.println("getTimetamp for sysdate :" +
    rset.getTimestamp(1).getClass().getName());
    }
     
    Prior to 9201, this will return
    getObject for sysdate  : java.sql.Timestamp      <<<<
    getDate for sysdate :java.sql.Date
    getTimetamp for sysdate :java.sql.Timestamp
     
    As of 9201 onward the following will be returned
     
    getObject for sysdate  : java.sql.Date        <<<<<
    getDate for sysdate :java.sql.Date            >> no change
    getTimetamp for sysdate :java.sql.Timestamp   >> no change
     
     
     
    Note: java.sql.Date has no time portion whereas java.sql.Timestamp does.
     
     
    With this change in Datatype mapping, some application will fail and/or generate
    incorrect results when JDBC driver is upgraded from 8i/ 9iR1 to 920x JBDC driver.
    To maintain compatibility and keep applications working after upgrade, a compatibility flag was
    Provided.  Developers now have some options:
     
    1>
    Use oracle.jdbc.V8Compatible flag.
     
    JDBC Driver does not detect database version by default.
    To change the compatibility flag for handling TIMESTAMP datatypes,
    connection property 'oracle.jdbc.V8Compatible' can be set to
    'true' and the driver behaves as it behaved in 8i, 901x, 9200
    (with respect to TIMESTAMPs).
    By default the flag is set to 'false'. In OracleConnection constructor
    the driver obtains the server version and set the compatibility flag
    Appropriately.
     
    java.util.Properties prop = new java.util.Properties ();
    prop.put ("oracle.jdbc.V8Compatible", "true");
    prop.put ("user", "scott");
    prop.put ("password", "tiger");
    String url ="jdbc:oracle:thin:@host:port:sid";
    Connection conn = DriverManager.getConnection (url,prop);
     
     
     
    With JDBC 10.1.0.x, in instead of the connection property, the following system
    property can be useed
    java -Doracle.jdbc.V8Compatible=true .....
     
     
     
    Note: This flag is a client only flag that governs the Timestamp and Date mapping.
    It does not affect any Database feature.
     
     
     
    2> use set/getDate and set/getTimestamp   when dealing with Date and TimeStamp column datatype accordingly.
    9i server  supports both Date and Timestamp column types
     
    DATE is mapped to  java.sql.Date and TIMESTAMP is mapped to java.sql.Timestamp
     
    I> using setTimestamp
     
    PreparedStatement pstmt = conn.prepareStatement(
    "SELECT count(*) from  tstable where tscol between ? and ?");
    // tscol of type Timetamp (or it can be Date)
     
    String s = new String("2003-01-14 10:00:00.000000000");
    Timestamp ts1 = Timestamp.valueOf(s);
    pstmt.setTimestamp(1, ts1); // Timestamp
     
    String s2 = new String("2003-01-16 10:00:00.000000000");
    Timestamp ts2 = Timestamp.valueOf(s2);
    pstmt.setTimestamp(2, ts2); // Timestamp
    ...
     
     
    II>using setDate
     
    PreparedStatement pstmt = conn.prepareStatement(
    "SELECT count(*) from  tstable where datecol between ? and ?");
    // datecole of type Date
     
    /*
    pstmt.setDate(1,new java.sql.Date(System.currentTimeMillis()));
    pstmt.setDate(2,new java.sql.Date(System.currentTimeMillis()));
    */
     
    SimpleDateFormat start_dt_in1 = new SimpleDateFormat("2002-09-18 00:00:00");
    SimpleDateFormat start_dt_in2 = new SimpleDateFormat("2003-09-18 00:00:00");
    pstmt.setDate(1,start_dt_in1);
    pstmt.setDate(2,start_dt_in2);
     
     
     
    Summary of  features afftected by oracle.jdbc.V8Compatible.
     
    Is backward compatible (with oracle.jdbc.V8Compatible)?
    
     
     
    * Examples:
    ..
    The following will fail   when using JDBC 9iR1, 9iR2 connecting 817 server since the
    817 did not support Timestamp
     
     
    Connection conn = DriverManager.getConnection(url, "scott",  "tiger");
    // Prepare a statement to cleanup the emp table
    Statement  stmt = conn.createStatement();
    try {
    stmt.execute("delete from EMP where EMPNO = 1");
    } catch (SQLException e) {
    }
    try {
    stmt.execute("INSERT INTO EMP (EMPNO, ENAME, HIREDATE) VALUES (1, 
    'ALI', {ts '2003-04-14 14:19:24.94'})");
    } catch (SQLException e) {
    e.printStackTrace();
    }
     
    Error : Exception in thread "main" java.sql.SQLException: ORA-00904: invalid column name
     
    Solution you need
    1> fix for Bug 2640192 (included in 9204)
    2> oracle.jdbc.V8Compatible", "true"
     
     
     
    In earlier versions of JDBC drivers  SQL FUNCTION "TS" was mapped to "to_date" .   So, the query
     
    select {ts '2002-10-18 18:02:00'} from dual;
    was translated by JDBC to,
    select TO_DATE ('2002-10-18 18:02:00',  'YYYY-MM-DD HH24:MI:SS') from dual;
     
     
    With 9i Timestamp is supported in the database and also by 9203 JDBC Drivers.
    So the query
     
    select {ts '2002-10-18 18:02:00'} from dual;
     
    is now translated  by JDBC to
     
    select TO_TIMESTAMP('2002-10-18 18:02:00', 'YYYY-MM-DD HH24:MI:.SS.FF') from dual;
     
     
    Known issues:  There is some performances issue when set/getTimestamp
    Bug 3037615
    Bug 2770935
    These bugs are very likely duplicate.
     
     
    The following code will no longer work with 9203+ unless V8 flag is set to true
     
    Timestamp start_dt_in = Timestamp.valueOf("2002-09-18 00:00:00");
    Timestamp now_period_start_dt ;
    PreparedStatement stmt = null;
    ResultSet rs = null;
     
    System.out.println("start_dt_in="+  start_dt_in );
     
    try {
    stmt = conn.prepareStatement( "SELECT TRUNC(?) FROM DUAL" );
    stmt.setTimestamp( 1, start_dt_in );
    rs = (OracleResultSet) stmt.executeQuery();
    if ( rs.next() ) {
    now_period_start_dt = rs.getTimestamp( 1 );
    System.out.println("Curr Period Start="+  now_period_start_dt );
    }
     
     
    will generate
    Exception in thread "main" java.sql.SQLException:
    ORA-932: inconsistent datatypes
     
     
    Reason : trunc ( )  supports Date columns and does not support  Timestamp  (this is an RDBMS issue).
    So, you need to set the V8 flag to true
     
    Another bug that changed the Date/Timetamp mapping is  2428427 to comly with
    J2EE 1.3 CTS.  This was fixed in 9014 and it specific to classesdmx*.zip/jar
    (the *dms* jar filed mainly used by iAS/OC4J).  These *dms* jar files, by the
    default value for oracle.jdbc.J2EE13Compliant  is true.  in classes111.zip
    classes12.jar and ojdbc14.jar/zip the default is false.
     
    One can toggel this flag  true/false by
     
    java -Doracle.jdbc.J2EE13Compliant=true|false
     
     
    example of of sample runs:
     
    query used :"select sysdate from dual"
    classes12dms.jar used.
     
     
    Driver Version      Object Type
    ==============      ===========
    9.0.1.3.0         java.sql.Timestamp >> fix for 2428427 NOT included
    9.0.1.4.0         java.sql.Date   >> fix for 2428427 INCLUDED
    9.0.1.5.0         java.sql.Date   >> fix for 2428427 INCLUDE
     
    In JDBC 9014+ ,to keep older (9013) behavior  simply run the application with
     
     
    $java -Doracle.jdbc.J2EE13Compliant=false .....
     
     
    However please note that J2EE 1.3 CTS require that Date to mapped to
    java.sql.Date.
    

    posted @ 2007-10-09 19:16 bluoy 閱讀(1122) | 評論 (0)編輯 收藏

    我們知道,在Struts 1.0中,我們只能在web.xml中為ActionServlet指定一個配置文件,這對于我們這些網(wǎng)上的教學(xué)例子來說當(dāng)然沒什么問題,但是在實(shí)際的應(yīng)用開發(fā)過程中,可能會有些麻煩。因?yàn)樵S多開發(fā)人員都可能同時需要修改配置文件,但是配置文件只能同時被一個人修改,這樣肯定會造成一定程度上的資源爭奪,勢必會影響開發(fā)效率和引起開發(fā)人員的抱怨。

    在Struts 1.1中,為了解決這個并行開發(fā)的問題,提出了兩種解決方案:

    1. 多個配置文件的支持
    2. 模塊的支持

     

    支持多個配置文件,是指你能夠?yàn)锳ctionServlet同時指定多個xml配置文件,文件之間以逗號分隔,比如Struts提供的MailReader演示例子中就采用該種方法。

    
                <!-- Action Servlet Configuration -->
                <servlet>
                <servlet-name>action</servlet-name>
                <servlet-class>
                    org.apache.struts.action.ActionServlet
                </servlet-class> <init-param> <param-name>config</param-name> <param-value>
    /WEB-INF/struts-config.xml,
    /WEB-INF/struts-config-registration.xml
    </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>

    這種方法可以很好地解決修改沖突的問題,不同的開發(fā)人員可以在不同的配置文件中設(shè)置自己的Action、ActionForm等等(當(dāng)然不是說每個開發(fā)人員都需要自己的配置文件,可以按照系統(tǒng)的功能模塊進(jìn)行劃分)。但是,這里還是存在一個潛在的問題,就是可能不同的配置文件之間會產(chǎn)生沖突,因?yàn)樵贏ctionServlet初始化的時候這幾個文件最終還是需要合并到一起的。比如,在struts-config.xml中配置了一個名為success的<forward>,而在struts-config-registration.xml中也配置了一個同樣的<forward>,那么執(zhí)行起來就會產(chǎn)生沖突。

    為了徹底解決這種沖突,Struts 1.1中引進(jìn)了模塊(Module)的概念。一個模塊就是一個獨(dú)立的子系統(tǒng),你可以在其中進(jìn)行任意所需的配置,同時又不必?fù)?dān)心和其它的配置文件產(chǎn)生沖突。因?yàn)榍懊嫖覀冎v過,ActionServlet是將不同的模塊信息保存在不同的ModuleConfig對象中的。要使用模塊的功能,需要進(jìn)行以下的準(zhǔn)備工作:

    1、為每個模塊準(zhǔn)備一個配置文件

    2、配置web.xml文件,通知控制器

    決定采用多個模塊以后,你需要將這些信息告訴控制器,這需要在web.xml文件進(jìn)行配置。下面是一個典型的多模塊配置:

    
                <init-param>
                <param-name>config</param-name>
                <param-value>
                    /WEB-INF/struts-config.xml
                </param-value> </init-param> <init-param> <param-name>config/customer</param-name> <param-value>
                    /WEB-INF/struts-config-customer.xml
                </param-value> </init-param> <init-param> <param-name>config/order</param-name> <param-value>
                    /WEB-INF/struts-config-order.xml
                </param-value> </init-param>

    要配置多個模塊,你需要在原有的一個<init-param>(在Struts 1.1中將其對應(yīng)的模塊稱為缺省模塊)的基礎(chǔ)之上,增加模塊對應(yīng)的<init-param>。其中<param-name>表示為config/XXX的形式,其中XXX為對應(yīng)的模塊名,<param-value>中還是指定模塊對應(yīng)的配置文件。上面這個例子說明該應(yīng)用有三個模塊,分別是缺省模塊、customer和order,它們分別對應(yīng)不同的配置文件。

    3、準(zhǔn)備各個模塊所需的ActionForm、Action和JSP等資源

    但是要注意的是,模塊的出現(xiàn)也同時帶來了一個問題,即如何在不同模塊間進(jìn)行轉(zhuǎn)發(fā)?有兩種方法可以實(shí)現(xiàn)模塊間的轉(zhuǎn)發(fā),一種就是在<forward>(全局或者本地)中定義,另外一種就是利用org.apache.struts.actions.SwitchAction。

    下面就是一個全局的例子:

    
                ...
                <struts-config>
                ...
                <global-forwards>
                <forward name="toModuleB"
                contextRelative="true"
                path="/moduleB/index.do"
                redirect="true"/>
                ...
                </global-forwards>
                ...
                </struts-config>
                

    可以看出,只需要在原有的path屬性前加上模塊名,同時將contextRelative屬性置為true即可。此外,你也可以在<action>中定義一個類似的本地<forward>。

    
                <action-mappings>
                <!-- Action mapping for profile form -->
                <action path="/login"
                type="com.ncu.test.LoginAction"
                name="loginForm"
                scope="request"
                input="tile.userLogin"
                validate="true">
                <forward name="success" contextRelative="true" path="/moduleA/login.do"/>
                </action>
                </action-mappings>
                

    如果你已經(jīng)處在其他模塊,需要轉(zhuǎn)回到缺省模塊,那應(yīng)該類似下面這樣定義,即模塊名為空。

    
                <forward name="success" contextRelative="true" path="/login.do"/>
                

    此外,你也可以使用org.apache.struts.actions.SwitchAction,例如:

    
                ...
                <action-mappings>
                <action path="/toModule"
                type="org.apache.struts.actions.SwitchAction"/>
                ...
                </action-mappings>
                ...
                

    posted @ 2007-08-17 16:25 bluoy 閱讀(192) | 評論 (0)編輯 收藏

    Oracle的systimestamp的精度與OS有關(guān)。例如:
    select systimestamp from dual;

    基于XP的輸出:07-07-03 16:07:10.328000 +08:00
    基于Solaris的輸出:07-07-03 16:09:18.328156 +08:00


    所以,如果DB中的表以timestamp類型的字段作唯一主鍵的話,在PC上就會藏有隱患:主鍵不唯一,因?yàn)榫冉档土耍l繁的insert操作很有可能產(chǎn)生相同的主鍵。而在Solaris上這個可能性就很低了。

    這點(diǎn)在DB設(shè)計(jì)中還是需要加以考慮的。

    posted @ 2007-07-03 16:43 bluoy 閱讀(3277) | 評論 (1)編輯 收藏

    java.util.Arrays.asList的BUG

    jdk 1.4對java.util.Arrays.asList的定義,函數(shù)參數(shù)是Object[]。所以,在1.4中asList()并不支持基本類型的數(shù)組作參數(shù)。

    jdk 1.5中,java.util.Arrays.asList的定義,函數(shù)參數(shù)是Varargs, 采用了泛型實(shí)現(xiàn)。同時由于autoboxing的支持,使得可以支持對象數(shù)組以及基本類型數(shù)組。

    但在使用過程中發(fā)現(xiàn)jdk1.5中存在一個BUG。就是等參數(shù)為基本類型的數(shù)組時,函數(shù)的行為發(fā)生了變異:它不是把這個數(shù)組轉(zhuǎn)換為List,而是把這個數(shù)組整體作為返回List中的第一個元素,要取得轉(zhuǎn)換后的結(jié)果,得首先get(0)才行。

    到網(wǎng)上google了一下,Sun好像認(rèn)為這并不是個問題。理由如下:
    Arrays.asList is now a vararg method, and the behavior is as intended:  asList(int[] ...)
    The Java generics implementation does not support non-reference type parameters.
    This is all standard Java 5.0 stuff.
    URL:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6353471

    雖然如此,但因此函數(shù)的行為就可能產(chǎn)生了歧義,對調(diào)用者還是會產(chǎn)生誤導(dǎo)的,我認(rèn)為這終歸還應(yīng)該是個問題的,如能解決是最好的了。

    posted @ 2007-07-03 14:55 bluoy 閱讀(891) | 評論 (0)編輯 收藏

    問題:同事不小心把項(xiàng)目DB中的一個表的數(shù)據(jù)delete all了。DB版本oracle 10g。
    網(wǎng)上簡單搜了一下,搞定。以下是過程:
    Oracle 10g開始,當(dāng)我執(zhí)行Drop Table時,Oracle也會把被刪除的表放到數(shù)據(jù)庫回收站(Database Recyclebin)里。這樣我們就可以用flashback table命令恢復(fù)被刪除的表,語法:
       Flashback table 表名 to before drop;

    開始恢復(fù),執(zhí)行以下命令:
    flashback table tmm2076 TO TIMESTAMP to_timestamp('2007-05-22
    12:00:00','yyyy-mm-dd hh24:mi:ss')
    彈出ORA-08189錯誤,需要執(zhí)行以下命令先:
    alter table tmm2076 enable row movement

    這個命令的作用是,允許oracle修改分配給行的rowid。

    然后再flashback,數(shù)據(jù)被恢復(fù)完畢。

    posted @ 2007-05-22 16:30 bluoy 閱讀(4102) | 評論 (2)編輯 收藏

    There's a field introspector written by a Velocity user in the Wiki. You can configure velocity.properties to reference this. It require velocity version 1.4.

    PublicFieldUberspect.java
    -------------------------------------------------------------------------------------------------------------
    /*
    * Copyright 2003-2004 The Apache Software Foundation.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
    package org.apache.velocity.tools.generic.introspection;
    import java.lang.reflect.Array;
    import java.lang.reflect.Field;
    import org.apache.velocity.util.introspection.Info;
    import org.apache.velocity.util.introspection.UberspectImpl;
    import org.apache.velocity.util.introspection.VelPropertyGet;
    import org.apache.velocity.util.introspection.VelPropertySet;
    /**
    * Uberspect implementation that exposes public fields.
    * Also exposes the explicit "length" field of arrays.
    *
    * <p>To use, tell Velocity to use this class for introspection
    * by adding the following to your velocity.properties:<br />
    *
    * <code>
    * runtime.introspector.uberspect = org.apache.velocity.tools.generic.introspection.PublicFieldUberspect
    * </code>
    * </p>
    *
    * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a>
    * @version $Id: $
    */
    public class PublicFieldUberspect extends UberspectImpl
    {
    /**
    * Default constructor.
    */
    public PublicFieldUberspect()
    {
    }
    /**
    * Property getter - returns VelPropertyGet appropos for #set($foo = $bar.woogie).
    * <br />
    * Returns a special {@link VelPropertyGet} for the <code>length</code> property of arrays.
    * Otherwise tries the regular routine.  If a getter was not found,
    * returns a {@link VelPropertyGet} that gets from public fields.
    *
    * @param obj the object
    * @param identifier the name of the property
    * @param i a bunch of information.
    * @return a valid <code>VelPropertyGet</code>, if it was found.
    * @throws Exception failed to create a valid <code>VelPropertyGet</code>.
    */
    public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
    throws Exception
    {
    Class clazz = obj.getClass();
    boolean isArray = clazz.isArray();
    boolean isLength = identifier.equals("length");
    if (isArray && isLength)
    {
    return new ArrayLengthGetter();
    }
    VelPropertyGet getter = super.getPropertyGet(obj, identifier, i);
    // there is no clean way to see if super succeeded
    // @see http://issues.apache.org/bugzilla/show_bug.cgi?id=31742
    try
    {
    getter.getMethodName();
    return getter;
    }
    catch (NullPointerException notFound)
    {
    }
    Field field = obj.getClass().getField(identifier);
    if (field != null)
    {
    return new PublicFieldGetter(field);
    }
    return null;
    }
    /**
    * Property setter - returns VelPropertySet appropos for #set($foo.bar = "geir").
    * <br />
    * First tries the regular routine.  If a setter was not found,
    * returns a {@link VelPropertySet} that sets to public fields.
    *
    * @param obj the object
    * @param identifier the name of the property
    * @param arg the value to set to the property
    * @param i a bunch of information.
    * @return a valid <code>VelPropertySet</code>, if it was found.
    * @throws Exception failed to create a valid <code>VelPropertySet</code>.
    */
    public VelPropertySet getPropertySet(Object obj, String identifier,
    Object arg, Info i) throws Exception
    {
    VelPropertySet setter = super.getPropertySet(obj, identifier, arg, i);
    if (setter != null)
    {
    return setter;
    }
    Field field = obj.getClass().getField(identifier);
    if (field != null)
    {
    return new PublicFieldSetter(field);
    }
    return null;
    }
    /**
    * Implementation of {@link VelPropertyGet} that gets from public fields.
    *
    * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a>
    * @version $Id: $
    */
    protected class PublicFieldGetter implements VelPropertyGet
    {
    /** The <code>Field</code> object representing the property. */
    private Field field = null;
    /**
    * Constructor.
    *
    * @param field The <code>Field</code> object representing the property.
    */
    public PublicFieldGetter(Field field)
    {
    this.field = field;
    }
    /**
    * Returns the value of the public field.
    *
    * @param o the object
    * @return the value
    * @throws Exception failed to get the value from the object
    */
    public Object invoke(Object o) throws Exception
    {
    return this.field.get(o);
    }
    /**
    * This class is cacheable, so it returns <code>true</code>.
    *
    * @return <code>true</code>.
    */
    public boolean isCacheable()
    {
    return true;
    }
    /**
    * Returns <code>"public field getter"</code>, since there is no method.
    *
    * @return <code>"public field getter"</code>
    */
    public String getMethodName()
    {
    return "public field getter";
    }
    }
    /**
    * Implementation of {@link VelPropertyGet} that gets length from arrays.
    *
    * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a>
    * @version $Id: $
    */
    protected class ArrayLengthGetter implements VelPropertyGet
    {
    /**
    * Constructor.
    */
    public ArrayLengthGetter()
    {
    }
    /**
    * Returns the length of the array.
    *
    * @param o the array
    * @return the length
    * @throws Exception failed to get the length from the array
    */
    public Object invoke(Object o) throws Exception
    {
    // Thanks to Eric Fixler for this refactor.
    return new Integer(Array.getLength(o));
    }
    /**
    * This class is cacheable, so it returns <code>true</code>.
    *
    * @return <code>true</code>.
    */
    public boolean isCacheable()
    {
    return true;
    }
    /**
    * Returns <code>"array length getter"</code>, since there is no method.
    *
    * @return <code>"array length getter"</code>
    */
    public String getMethodName()
    {
    return "array length getter";
    }
    }
    /**
    * Implementation of {@link VelPropertySet} that sets to public fields.
    *
    * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a>
    * @version $Id: $
    */
    protected class PublicFieldSetter implements VelPropertySet
    {
    /** The <code>Field</code> object representing the property. */
    private Field field = null;
    /**
    * Constructor.
    *
    * @param field The <code>Field</code> object representing the property.
    */
    public PublicFieldSetter(Field field)
    {
    this.field = field;
    }
    /**
    * Sets the value to the public field.
    *
    * @param o the object
    * @param value the value to set
    * @return always <code>null</code>
    * @throws Exception failed to set the value to the object
    */
    public Object invoke(Object o, Object value) throws Exception
    {
    this.field.set(o, value);
    return null;
    }
    /**
    * This class is cacheable, so it returns <code>true</code>.
    *
    * @return <code>true</code>.
    */
    public boolean isCacheable()
    {
    return true;
    }
    /**
    * Returns <code>"public field setter"</code>, since there is no method.
    *
    * @return <code>"public field setter"</code>
    */
    public String getMethodName()
    {
    return "public field setter";
    }
    }
    }
    


    See
    http://wiki.apache.org/jakarta-velocity/PublicFieldUberspect

    posted @ 2007-05-18 10:10 bluoy 閱讀(274) | 評論 (0)編輯 收藏

    開發(fā)要求:
    為了便于維護(hù),頁面端js中的錯誤信息要求不能硬編碼,要根據(jù)java端定義的Message對應(yīng)的常量Key動態(tài)獲得。

    按照velocity常規(guī)做法,無法用VTL語言使用static類。調(diào)查了一下,原來velocity還是提供了變通了的實(shí)現(xiàn)方案的,官方論壇上還有就這一問題的爭論--“Add Support for Static Utility Classes”。

     
    基本上集中于兩種思路:static class wrapper 和 put class into context。
    前者就是作一個static class 的托管類,將托管類的實(shí)例放到context中。
    1.3.1版中對應(yīng)實(shí)現(xiàn)為org.apache.velocity.app.FieldMethodizer。
    后者的想法是先把static類的Class放到context中,然后模版引擎在碰到Class對象時,優(yōu)先在java.lang.Class中尋找對應(yīng)的調(diào)用,然后再查找static class的調(diào)用。個人感覺這種思路比較好,用戶使用比較簡單直接,不需要額外的wrapper類。但官方好像更鐘情于前者。計(jì)劃在未來的1.6版中提供支持。

    附帶遇到的其他限制:
    1. velocity 1.3.1版不能正常處理jdk1.5中的可變參數(shù)(Varargs) 特性。可變參數(shù)(Varargs) 其實(shí)使用對應(yīng)類型的數(shù)組來實(shí)現(xiàn)的。velocity會因?yàn)槠ヅ洳坏綄?yīng)的函數(shù)原型而調(diào)用失敗。其他版本未作驗(yàn)證。
    2. velocity 1.3.1版不能正常處理jdk1.5中的enum特性。因?yàn)閑num其實(shí)是按類來對待的。而velocity內(nèi)部對類的處理是“取得所有的public的Methods”。所以類內(nèi)部定義的enum類型的常量無法取到。這個處理請參見:org.apache.velocity.util.introspection.ClassMap。
    3. velocity只能調(diào)用類/對象的methods, 無法直接使用public的attributs。原因如2。同時可以參照
    Access to public member variable of a class

    posted @ 2007-05-17 14:52 bluoy 閱讀(2451) | 評論 (0)編輯 收藏

    下面這種現(xiàn)象在項(xiàng)測試階段多次出現(xiàn)DBoracle 10g。未作其他版本驗(yàn)證

    test schema下共有12sequence.

    其中case_seq的定義為

    create sequence CASE_SEQ minvalue 1 maxvalue 99999999 start with 11531 increment by 1 cache 20;

     

    應(yīng)用程序出的LOG如下:

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

    行號 出信息

    ......

    962 ('000000011531','000000000001','0','電話',to_date('2007/04/24

    15:38','yyyy/mm/dd hh24:mi'),

    ......

    2304 ('000000011532','000000000001','0','電話',to_date('2007/04/24

    15:44','yyyy/mm/dd hh24:mi'),

    ......

    6779 ('000000011551','000000000001','0','電話',to_date('2007/04/24

    15:58','yyyy/mm/dd hh24:mi'),

    ......

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

     

    *1 取得sequence句如下:select lpad(case_seq.nextval,12,0) as case_id from dual

    *2 省略號代表其他操作,其中包含大量DB操作,包括1次其他sequence調(diào)用。但無

    case_seq調(diào)用。

     

    故障原因調(diào)查

    根據(jù)現(xiàn)象初計(jì)好像和sequence_cache_entries初始化參數(shù)有關(guān)

    調(diào)查發(fā)現(xiàn)這個參數(shù)從Oracle 8.1.7后就被棄了。不知10g中是否對應(yīng)參數(shù)?

     

    亦或是否有其他原因造成這種現(xiàn)象。尚待調(diào)查。

    posted @ 2007-05-09 17:10 bluoy 閱讀(392) | 評論 (0)編輯 收藏

    JVM‘s current path: 
       System.getProperty("user.dir");
    但是JDK中使用curdir的方法并不一致,比如File.exists() VS File.getAbsolutePath().
    user.dir可以通過setProperty()修改,這樣就會導(dǎo)致上面兩個函數(shù)結(jié)果相左。
    不知道這是否算是JDK的一個BUG.

    IDE Debug mode:
       curdir往往由所使用的IDE來決定,比如eclipse,是當(dāng)前打開的project的根。
       這與程序?qū)嶋H運(yùn)行時的curdir是不同的。在debug模式下需要考慮這一點(diǎn)。   

    Java program runtime:
       curdir是classes或bin。
       取得方法:DummyClass.class.getResource("/").getPath();

    posted @ 2007-05-08 17:23 bluoy 閱讀(191) | 評論 (0)編輯 收藏

    僅列出標(biāo)題
    共4頁: 上一頁 1 2 3 4 下一頁 
    主站蜘蛛池模板: 苍井空亚洲精品AA片在线播放 | 亚洲成av人片不卡无码| 久久99久久成人免费播放| 亚洲国产精品成人一区| 一级毛片免费在线| 超清首页国产亚洲丝袜| 中文字幕成人免费高清在线| 久久精品亚洲男人的天堂| 拍拍拍无挡免费视频网站| 亚洲高清在线播放| 91麻豆国产免费观看| 亚洲国产美女福利直播秀一区二区| 久久福利资源网站免费看| 亚洲一卡2卡3卡4卡乱码 在线| 在线播放免费播放av片| 美女露100%胸无遮挡免费观看| 亚洲国产精品毛片av不卡在线 | 亚洲中文字幕人成乱码| 精品国产免费观看一区| 一区二区三区精品高清视频免费在线播放 | 在线观看免费视频一区| 亚洲综合色一区二区三区小说| 国产精品入口麻豆免费观看| 亚洲日韩精品国产3区| 亚洲成a人片在线观看老师| 免费一区二区三区| www.亚洲成在线| 亚洲欧洲中文日韩av乱码| 久久成人免费播放网站| 亚洲午夜一区二区三区| 亚洲国产成人乱码精品女人久久久不卡| 丁香花在线视频观看免费 | 日日摸日日碰夜夜爽亚洲| 亚洲精品无码午夜福利中文字幕| 30岁的女人韩剧免费观看| 女bbbbxxxx另类亚洲| 亚洲一区二区影院| 国产男女猛烈无遮档免费视频网站 | 亚洲最新中文字幕| 亚洲成AV人网址| 亚洲一级毛片免费看|