软体印象

Kavin
posts - 13, comments - 0, trackbacks - 0, articles - 0

2010年3月25日

 

DECLARE
  v_test_varray VARCHAR_VARRAY_TYPE := VARCHAR_VARRAY_TYPE('57610',
                                                           '61368',
                                                           '73111',
                                                           '37208',
                                                           '57639');
                                                           
V_SQL        VARCHAR2(32767);
    V_SQL_IN     VARCHAR2(32767);
    V_SQL_ROWNUM VARCHAR2(32767);
    V_ORDER      VARCHAR2(32767);
    TYPE number_index_by_string IS TABLE OF NUMBER INDEX BY VARCHAR2(10);
    v_evt_id_list  NUMBER_INDEX_BY_STRING;
    
Begin
  --orderArray VARCHAR_VARRAY_TYPE%type := VARCHAR_VARRAY_TYPE('11','22','33','44','55');

/*  
  FOR i IN v_test_varray.FIRST .. v_test_varray.LAST LOOP
    IF v_test_varray.EXISTS(i) THEN
      DBMS_OUTPUT.put_line(i);
    END IF;
  END LOOP;
  
*/
  
  V_ORDER := Func_LIST_TO_ORDER(v_test_varray, 'A.COL_NAME');
  DBMS_OUTPUT.put_line('V_ORDER='||V_ORDER);
  
  V_SQL := 'SELECT * FROM TABLEA A'
           || ' WHERE '
           || ''
           || ''
           || ''
           || ''
           ;
  V_SQL := V_SQL || ' ( ' ||
               FUNC_LIST_TO_IN_SQL(v_test_varray,
                                    'COL_NAME',
                                    ''''|| ')';
    V_SQL := V_SQL  ||
             ' ORDER by ( ' || V_ORDER || ')';
             
  DBMS_OUTPUT.put_line('V_SQL='||V_SQL);

--- SET v_evt_id_list number_index_by_string

FOR i IN v_test_varray.FIRST .. v_test_varray.LAST
  LOOP
     IF v_test_varray.EXISTS (i)
     THEN
        DBMS_OUTPUT.put_line (i);
        v_evt_id_list(v_test_varray(i)) := i;
     END IF;
  END LOOP;
  
--- TEST v_evt_id_list number_index_by_string
  FOR i IN v_evt_id_list.FIRST .. v_evt_id_list.LAST
  LOOP
     IF v_evt_id_list.EXISTS (i)
     THEN
        DBMS_OUTPUT.put_line (i||' = '||v_evt_id_list(i) );
     END IF;
  END LOOP;
  
-- GET v_evt_id_list number_index_by_string
  DBMS_OUTPUT.put_line (v_evt_id_list('73111') );

posted @ 2013-02-04 16:47 Kavin 阅读(231) | 评论 (0)编辑 收藏

1. config servlet in web.xml
 <servlet>
     <servlet-name>addressData</servlet-name>
     <servlet-class>com.xxx.webapp.AddressDataAutoCompleteServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
    </servlet>
   
2. set autocomplete in JSP
$().ready(function() {
 
 $("#addressLine1").autocomplete("<%=StrUtils.filterStr(request.getContextPath())%>/servlet/addressData?paramName=addressLine");
 $("#addressLine2").autocomplete("<%=StrUtils.filterStr(request.getContextPath())%>/servlet/addressData?paramName=addressLine2");
 $("#addressLine3").autocomplete("<%=StrUtils.filterStr(request.getContextPath())%>/servlet/addressData?paramName=addressLine3");
 $("#addressCity").autocomplete("<%=StrUtils.filterStr(request.getContextPath())%>/servlet/addressData?paramName=addressCity");
 $("#addressPostCode").autocomplete("<%=StrUtils.filterStr(request.getContextPath())%>/servlet/addressData?paramName=addressPostCode");
 $("#firstFocusObj").focus();
});

<html:text name="" tabindex="9" style="color: grey;" onclick="clearAddressValue(this)" styleId="addressLine1" value='<%=request.getAttribute("postalAddress1") == null ? defalutAddressValue : (String)request.getAttribute("postalAddress1")%>' property="TLContactDetailForm.postalAddress1" size="50" maxlength="50" styleClass="inputText2"></html:text>

<input type="text" name="TLContactDetailForm.postalAddress1" maxlength="50" size="50" tabindex="9" value="Start typing your address and we will finish it for you" onclick="clearAddressValue(this)" id="addressLine1" style="color: grey;" class="inputText2">

3. return addresses in java class: AddressDataAutoCompleteServlet.java

 

package com.xxxxxx.webapp;

import com.xxxxxx.exception.ServiceException;
import com.xxxxxx.util.StrUtils;
import com.xxxxxx.webapp.context.ServiceLocator;
import com.xxxxxx.util.AddressShow;

import java.io.IOException;
import java.io.PrintWriter;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;


/**
 * Servlet implementation class AddressDataAutoCompleteServlet
 */
public class AddressDataAutoCompleteServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public Logger LOG = Logger.getLogger(this.getClass().getName());

    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddressDataAutoCompleteServlet() {
        super();
    }
   
    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doGet(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
        String paramName = request.getParameter("paramName");
        String paramValue = request.getParameter("q");
        LOG.info(paramName);
        LOG.info(paramValue);

        List list = new ArrayList();

        try {
            list = ServiceLocator.getAddressService()
                                 .searchAddressList(paramName, paramValue);
        } catch (ServiceException e) {
         LOG.error(e.getMessage(),e);
        }

        PrintWriter t_PW = response.getWriter();
       
        for (int i = 0; i < list.size(); i++) {
            String address = StrUtils.toTitleCase((String) list.get(i));

            if (paramName.equals("addressLine")) {
             AddressShow.showAddress(t_PW,address);
            } else if (paramName.equals("addressLine1")) {
             AddressShow.showAddress(t_PW,address);
            } else if (paramName.equals("addressLine2")) {
             AddressShow.showAddress(t_PW,address);
            } else if (paramName.equals("addressLine3")) {
             AddressShow.showAddress(t_PW,address);
            } else if (paramName.equals("addressCity")) {
             AddressShow.showAddress(t_PW,address);
            } else if (paramName.equals("addressPostCode")) {
             AddressShow.showAddress(t_PW,address);
            }
        }
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doPost(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}

 

 


------
AddressShow.java

package com.intl.cigna.util;

import java.io.PrintWriter;

public class AddressShow
{
  public static void showAddress(PrintWriter pw, String input)
  {
    pw.write(input + "\n");

  }
}

posted @ 2012-06-07 22:39 Kavin 阅读(298) | 评论 (0)编辑 收藏

Unauthorized access to users data via Browser’s Cach

Solution:


1 <%  response.setHeader("Pragma""no-cache"); 
2                 response.setHeader("Cache-Control""no-store"); 
3                 response.setHeader("Expires""0"); 
4                 response.setDateHeader("Expires"-1); 
5 %>
6 

posted @ 2011-06-09 17:53 Kavin 阅读(243) | 评论 (0)编辑 收藏

SSH2中,直接获取SEQUENCE的NEXTVAL

使用Spring的 类 org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer

Spring配置文件:
 1     <bean id="userDao" class="com.xx.dao.impl.UserDAOImpl">
 2         <property name="sessionFactory" ref="sessionFactory" />
 3         <property name="seqGenerator" ref="seqDispGenerator"></property>
 5     </bean>
 6     
 7     <bean id="seqDispGenerator" class="org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer">
 8         <property name="dataSource" ref="dataSource"></property>
 9         <property name="incrementerName" ><value>SEQ_DISP_ID</value></property>
10     </bean>



UserDAOImpl.java中引用:
private OracleSequenceMaxValueIncrementer seqGenerator;
    
    

    
/**
     * 
@return the seqGenerator
     
*/
    
public OracleSequenceMaxValueIncrementer getSeqGenerator() {
        
return seqGenerator;
    }

    
/**
     * 
@param seqGenerator the seqGenerator to set
     
*/
    
public void setSeqGenerator(OracleSequenceMaxValueIncrementer seqGenerator) {
        
this.seqGenerator = seqGenerator;
    }

UserDAOImpl.java中调用:
1 System.out.println("---------------------- this.seqGenerator().nextIntValue="+this.seqGenerator.nextIntValue());


posted @ 2011-05-06 14:24 Kavin 阅读(2686) | 评论 (0)编辑 收藏

Hibernate ID generator 自定义主键生成器

/**
 * 
 
*/
package com.ge.hc.eapp.generator;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.hibernate.HibernateException;
import org.hibernate.MappingException;

import org.hibernate.dialect.Dialect;

import org.hibernate.engine.SessionImplementor;

import org.hibernate.id.Configurable;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.PersistentIdentifierGenerator;

import org.hibernate.type.Type;

import java.io.Serializable;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Properties;

/**
 * 
@author Kavin
 *
 
*/
public class DispNoGenerator implements IdentifierGenerator, Configurable {
    
private static final Log log = LogFactory.getLog(DispNoGenerator.class);

    
//存储最大值的数组的容量
    private static final int MAX_CAPACITY = 2000;

    
/* 同步锁 */
    
private static final Object lock = new Object();

    
//存储表存储在数组中的索引值
    private static Map map = new HashMap();

    
//最大值数组
    private static long[] seqs = new long[MAX_CAPACITY];

    
//最大值数组已经使用的容量
    private static int lastIndex;

    
//递增步长,默认加1
    private int step = 1;
    
private String key;
    
private String sql;
    
private Connection connection;
    
private Class returnClass;

    
public Serializable generate(SessionImplementor session, Object object)
        
throws HibernateException {
        
// TODO Auto-generated method stub
        connection = session.connection();

//        long seq = -1;

        
//找到索引值
//        int index = findIndex();

//        //把最大值加1
//        seqs[index] = seqs[index] + step;
//
//        seq = seqs[index];
        
        String strGenerateId 
= null;
        System.out.println(
"this.sql="+this.sql);
        
try {
            
long t_SeqNo = this.getSeqValue();
        
        System.out.println(
"t_SeqNo="+t_SeqNo);
       
        
//得到流水号,是自己写的工具类生成的.形式为000x
        String seqStr = String.valueOf(t_SeqNo);
        
//JspFormate.currentFormateORM(seq);
        
//得到yymmdd,是自己写的方法工具类生成的yymmdd
        String preDate = "20110506";
        
//得到hhmmss,是自己写的工具类获取的hhmmss
        
//String preHour = JspFormate.dateFormateOnlyHHMMSSORM(new Date());
        String preHour = "1035";
        strGenerateId 
= preDate + preHour + seqStr;
        } 
catch (SQLException e) {
            log.error(e);
            e.printStackTrace();
        }

        
return strGenerateId;
    }

    
/**
     * 找到表中自动增长字段存储在数组中的索引值
     * 
@return 索引值
     
*/
    
private int findIndex() {
        
int index = 0;

        
//首先中缓存中取出索引值
        Integer integer = (Integer) map.get(key);

        
//如果没有找到就从数据库中读出最大值并进行cache
        if (null == integer) {
            
//double check lock
            synchronized (lock) {
                integer 
= (Integer) map.get(key);

                
if (null == integer) {
                    
long maxvalue = 1;

                    
try {
                        maxvalue 
= this.getSeqValue();
                    } 
catch (SQLException e) {
                        log.error(e);
                    }
                    maxvalue 
= new Long(0).longValue();

                    integer 
= new Integer(lastIndex++);
                    seqs[integer.intValue()] 
= maxvalue;
                    map.put(key, integer);
                }
            }
        }

        index 
= integer.intValue();

        
return index;
    }

    
public void configure(Type type, Properties params, Dialect d)
        
throws MappingException {
        
//     取出table参数
        String table = params.getProperty("table");

        
if (table == null) {
            table 
= params.getProperty(PersistentIdentifierGenerator.TABLE);
        }

        
//取出column参数
        String column = params.getProperty("column");

        
if (column == null) {
            column 
= params.getProperty(PersistentIdentifierGenerator.PK);
        }

        
//表的sehcma参数
        String schema = params.getProperty(PersistentIdentifierGenerator.SCHEMA);

        returnClass 
= type.getReturnedClass();

        
//取出step参数
        String stepvalue = params.getProperty("step");

        
if ((null != stepvalue) && !"".equals(stepvalue.trim())) {
            
try {
                step 
= Integer.parseInt(stepvalue);
            } 
catch (Exception e) {
                log.error(e);
            }
        }

        
//构造存储在Map中的索引值的key name
        key = table + "_$_" + column;

        
//根据参数构造取最大值的SQL
        sql = "select SEQ_COMPANY_ID.nextval from dual";

        
    }

    
/**
     * 取指定SEQUENCE的值,不存在记录返回0
     * 
@return Sequence最大值
     * 
@throws SQLException if sql error occurs.
     
*/
    
private long getSeqValue() throws SQLException {
        
long maxvalue = 0;

        PreparedStatement st 
= connection.prepareStatement(sql);
        System.out.println(
"============================================" + sql);
        ResultSet rs 
= null;

        
try {
            rs 
= st.executeQuery();

            
if (rs.next()) {
                maxvalue 
= rs.getLong(1);
            }

            sql 
= null;
        } 
finally {
            
if (rs != null) {
                rs.close();
            }

            st.close();
        }

        
return maxvalue;
    }
    
    
/**
     * 取指定表中id字段的最大值,不存在记录返回0
     * 
@return 最大值
     * 
@throws SQLException if sql error occurs.
     
*/
    
private long getMaxvalue() throws SQLException {
        
long maxvalue = 0;

        PreparedStatement st 
= connection.prepareStatement(sql);
        System.out.println(
"============================================" + sql);
        ResultSet rs 
= null;

        
try {
            rs 
= st.executeQuery();

            
if (rs.next()) {
                maxvalue 
= rs.getLong(1);
            }

            sql 
= null;
        } 
finally {
            
if (rs != null) {
                rs.close();
            }

            st.close();
        }

        
return maxvalue;
    }
}

Hibernate 配置文件

<id name="userId" type="java.lang.String">
            
<column name="USER_ID" />
            
<generator class="com.xx.generator.DispNoGenerator" />
        
</id>


posted @ 2011-05-06 13:42 Kavin 阅读(2129) | 评论 (0)编辑 收藏

     摘要: Normal 0 7.8 pt 0 2 false false false EN-US ZH-CN X-NONE ...  阅读全文

posted @ 2011-05-05 12:33 Kavin 阅读(2369) | 评论 (0)编辑 收藏

 

Description:.

To bring up System Properties:

1.       Click Start and then Control Panel. From the Control Panel, double click System.

2.        Another way to bring up this box is to right click the My Computer on your desktop. From the menu, select Properties.

Solution:

1.       参考http://www.passcape.com/windows_run_commands

除了这两种方式外,还有一种直接运行system32下面的命令文件方式

运行C:"WINDOWS"system32 下面的sysdm.cpl

posted @ 2011-04-19 11:40 Kavin 阅读(254) | 评论 (0)编辑 收藏

 

Description: @Override该标记是为了增强程序在编译时候的检查,JDK1.5下,如果该方法并不是一个覆盖父类的方法,在编译时编译器就会报告错误。

Analisys:

 

 1public class A {
 2 public void method(int i) {
 3 }

 4}

 5
 6public class B extends A {
 7 @Override
 8 public void method(int i) {
 9 }

10
11//如果如下定义,就会在编译时出现一个错误,因为不是覆盖父类的方法
12@Override
13 public void method(int i, String p_Str) {
14 }

15
16}

17


JDK1.6正常,支持对接口的实现的@Override

 1public interface iA {
 2
 3 public void method(int i) {
 4
 5 }

 6
 7}

 8
 9public class B implements iA {
10
11 //JDK1.5下会报错,JDK1.6下可以
12
13 @Override
14
15 public void method(int i, int j) {
16
17 }

18
19}

20

posted @ 2011-04-18 17:32 Kavin 阅读(809) | 评论 (0)编辑 收藏

 

Description:
Incompatible JVM- Version 1.4.2_03 of the JVM is not suitable for th is product. Version:1.5 or greater is required.



Analisys:

安装Oracle Client 9/10, Path 被设置为Oracle自带的JDK 1.4, 启动高版本Eclipse(eclipse-jee-helios-SR1-win32.exe), 就默认用Oracle自带的JDK 1.4,这样就会有问题。

Solution:

多种解决方案

1.       修改环境变量: Path = %JAVA_HOME%"bin;%PATH% 
权限的问题,我没有选择这个解决方案。

2.       修改Eclipse启动项:修改Eclipse快捷方式的属性里面的目标: 
D:"tool"eclipse-jee-helios-SR1-win32"eclipse"eclipse.exe -vm "C:"Program Files"Java"jdk1.5.0_05"bin"javaw.exe"

posted @ 2011-04-15 09:53 Kavin 阅读(461) | 评论 (0)编辑 收藏

 

代码:
Class XX implements InterfaceYY{
    @override
    function funcXX(){
    }
}

Eclipse报错:   must override a superclass implements

Analisys:
1. @override 可以针对 Interface; 不过最好用另外一个annotation: @implement
2. java5 java6 支持泛型
3. eclipse 里面的compile版本是JDK 5

Solution:
eclipse 里面的compile版本是JDK 5 -> 改成 JDK6

posted @ 2011-04-07 14:30 Kavin 阅读(719) | 评论 (0)编辑 收藏

 

There is one problem with the Tag of "<tablib>" , when creating struts web project.. The error prompt as "cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'"

<web-app>

  .....

 <taglib>
     <taglib-uri>/tags/struts-tiles</taglib-uri>
     <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
   </taglib>
</web-app>

 

Solution: Surround a tag of "jsp-config" :

</web-app>

...

  <jsp-config>
   <taglib>
     <taglib-uri>/tags/struts-tiles</taglib-uri>
     <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
   </taglib>
  </jsp-config>
 
</web-app>

posted @ 2010-04-28 15:16 Kavin 阅读(356) | 评论 (0)编辑 收藏

    比如查看spring.jar 中的Spring版本:
查看 spring.jar\META-INF\MANIFEST.MF
Manifest-Version: 1.0
Export-Package: org.springframework.orm.jpa;uses:="org.apache.commons.
 logging,org.aopalliance.intercept,org.springframework.beans,org.sprin
 gframework.dao.support,org.springframework.instrument.classloading,ja
 vax.persistence,...

Spring-Version: 2.5.4
Implementation-Title: Spring Framework
Implementation-Version: 2.5.4
Tool: Bnd-0.0.208

...

这里的2.5.4就是这个spring的版本。

posted @ 2010-04-21 17:51 Kavin 阅读(2962) | 评论 (0)编辑 收藏

 

1. 使用宏操作 录制宏并添加快捷键(ctl+shift+h);选中要修改的图片,使用快捷键。

Sub ResizeShape()

'

' ResizeShape Macro

' Macro recorded 2010-3-25 by Kavin

'

    Selection.InlineShapes(1).Fill.Visible = msoFalse

    Selection.InlineShapes(1).Fill.Solid

    Selection.InlineShapes(1).Fill.Transparency = 0#

    Selection.InlineShapes(1).Line.Weight = 0.75

    Selection.InlineShapes(1).Line.Transparency = 0#

    Selection.InlineShapes(1).Line.Visible = msoFalse

    Selection.InlineShapes(1).LockAspectRatio = msoTrue

    Selection.InlineShapes(1).Height = 198.15

    Selection.InlineShapes(1).Width = 264.45

    Selection.InlineShapes(1).PictureFormat.Brightness = 0.5

    Selection.InlineShapes(1).PictureFormat.Contrast = 0.5

    Selection.InlineShapes(1).PictureFormat.ColorType = msoPictureAutomatic

    Selection.InlineShapes(1).PictureFormat.CropLeft = 0#

    Selection.InlineShapes(1).PictureFormat.CropRight = 0#

    Selection.InlineShapes(1).PictureFormat.CropTop = 0#

    Selection.InlineShapes(1).PictureFormat.CropBottom = 0#

End Sub

2. 使用宏程序操作 创建宏程序,然后执行

Sub batchResizeShape()

    Dim doc     As Document

  Dim i     As Integer

  Set doc = ActiveDocument 

  For i = 1 To doc.InlineShapes.Count

  'doc.InlineShapes 

      'doc.Shapes(i).ScaleHeight 0.5, msoFalse, msoScaleFromMiddle

      'doc.Shapes(i).ScaleWidth 0.5, msoFalse, msoScaleFromMiddle

      doc.InlineShapes(i).Height = 198.15

    doc.InlineShapes(i).Width = 264.45

  Next i

 

End Sub

posted @ 2010-03-25 16:17 Kavin 阅读(6664) | 评论 (0)编辑 收藏