Tuesday, November 4, 2014

Useful blog urls

1.Jenkins or hudson quick start tutorial

2.Setting up subversion on widows

3.Jsp Editor not showing in eclipse

If you've installed Juno EE it should support .jsp editor.
Most probably, your Eclipse is "starting" with java less than v1.6 (for me it was as well, I have 1.3, 1.5, 1.6 javas installed; default was 1.5 and Eclipse was starting with it automatically)
I solved same problem with below way:
1) Right click on Juno shortcut and click Properties
2) In the field "Target"
You already should have something like below:
"D:\PROGRAM INSTALL\eclipse-jee-juno-SR2-win32\eclipse\eclipse.exe"
Add to the end of that line one more command as below (show to Eclipse with which java version it should start)
-vm "C:\Program Files\Java\jdk1.6.0_20\bin\java.exe"
My target looks like below:
"D:\PROGRAM INSTALL\eclipse-jee-juno-SR2-win32\eclipse\eclipse.exe" -vm "C:\Program Files\Java\jdk1.6.0_20\bin\java.exe"
3) Start Eclipse with changed target using your shortcut
4) On .jsp file now you will be able to chose "Open with --> JSP Editor





5.http://www.corejavainterviewquestions.com/idiots-guide-big-o/

6. http://learngitbranching.js.org/



Solr Blog :http://blog.thedigitalgroup.com/dattatrayap/

















Tuesday, September 30, 2014

Oracle Stored Procedure Simple Example


procedure insertValpakCatsMapping(op_company_id IN DISCOUNT_OWNER.COMP_VALPAK_CAT.COMPANYID%type,
            op_category_ids IN common.idlist,
           op_user_id IN DISCOUNT_OWNER.COMP_VALPAK_CAT.ADD_BY_USERID%type)IS
    begin
       delete from discount_owner.COMP_VALPAK_CAT where COMPANYID = op_company_id;
      insert into discount_owner.COMP_VALPAK_CAT
         (companyid,
          VALPAK_CATEGORY_ID,
          add_by_userid,
          change_by_userid)
       select op_company_id,
              catids.column_value,
              op_user_id,
              op_user_id
       from table(cast(op_category_ids as common.idlist)) catids
       minus
       select op_company_id,
              catids.column_value,
              op_user_id,
              op_user_id
       from discount_owner.COMP_VALPAK_CAT  optx, table(cast(op_category_ids as common.idlist)) catids
       where optx.companyid = op_company_id and
             optx.VALPAK_CATEGORY_ID = catids.column_value;
       end;
      

Oracle procedure:passing array to sql procedure from java code

Oracle Side:
step1: create type IDLIST
CREATE OR REPLACE TYPE COMMON."IDLIST"  is table of number ;

Step2: Create proc for inserting a array of categories for a company id

procedure insertValpakCatsMapping(op_company_id IN DISCOUNT_OWNER.COMP_VALPAK_CAT.COMPANYID%type,
            op_category_ids IN common.idlist,
           op_user_id IN DISCOUNT_OWNER.COMP_VALPAK_CAT.ADD_BY_USERID%type)IS
   begin
      insert into discount_owner.COMP_VALPAK_CAT
         (companyid,
          VALPAK_CATEGORY_ID,
          add_by_userid,
          change_by_userid)
       select op_company_id,
              catids.column_value,
              op_user_id,
              op_user_id
       from table(cast(op_category_ids as common.idlist)) catids
       minus
       select op_company_id,
              catids.column_value,
              op_user_id,
              op_user_id
       from discount_owner.COMP_VALPAK_CAT  optx, table(cast(op_category_ids as common.idlist))     catids
       where optx.companyid = op_company_id and
             optx.VALPAK_CATEGORY_ID = catids.column_value;
 end;
      


Java  Calling Code:


Class Test {
    private static ArrayDescriptor _numericDescriptor = null;

public void insertValpakSubcategories(String companyid,
            ArrayList<Integer> cats,long userId)throws SQLException {
       
            Connection conn = null;
            CallableStatement stmt = null;
            ResultSet rs = null;

            try {
              conn = PoolManager.getInstance().getConnection(_pool);
              stmt = conn.prepareCall("{call CMT_COMPANY_PACKAGE.insertValpakCats(?,?,?)}");
              Array categoryIds = createSqlIntegerArray(cats, conn);
              stmt.setString(1,companyid);
              stmt.setArray(2, categoryIds);
              stmt.setLong(3,userId);
              stmt.execute();
              stmt.close();
            }catch(SQLException e){
                LOGGER.error("error in saving subcategories for valpak",e);
                throw e ;
            }
       
    }
   
    public static Array createSqlIntegerArray(ArrayList integerList, Connection conn) {
        if (_numericDescriptor == null) {
            createArrayDescriptors();
        }
        try {
            return new oracle.sql.ARRAY(_numericDescriptor, conn, integerList.toArray());
        }
        catch(SQLException e) {
            LOGGER.error("Error creating sql integer array.", e);
            return null;
        }
    }
   
    private static void createArrayDescriptors() {
        if(_numericDescriptor==null) {
            Connection conn = null;
            try {
                conn = PoolManager.getInstance().getConnection(null);
                _numericDescriptor = ArrayDescriptor.createDescriptor("COMMON.IDLIST", conn);
                _stringDescriptor = ArrayDescriptor.createDescriptor("COMMON.VARLIST", conn);
            } catch(SQLException e) {
                LOGGER.error("Exception creating array descriptors...", e);
            }
            finally {
                cleanUp(conn, null, null);
            }
        }
    }

}

 for more info please read
http://betteratoracle.com/posts/26-passing-arrays-between-java-and-oracle-procedures