ArtinSoft's Blogs

Software Migration Experts
Welcome to ArtinSoft's Blogs Sign in | Join | Help
in Search

Mauricio Rojas Blog

January 2007 - Posts

  • 57016 or the Unavailable table

    The idea was to create a harry potter like title jeje.
    Today I had a new issue with DB2 (everyday you learn something new).
    I got to work and we had some tables that you could not query or do anything. The system reported something like:
    SQL0668N  Operation not allowed for reason code "1" on table "MYSCHEMA.MYTABLE".
    SQLSTATE=57016
    So I started looking what is an 57016 code????

    After some googling I found that the table was in an "unavailable state". OK!!
    But how did it got there? Well that I still I'm not certain. And the most important. How do I get it out of that state?????
    Well I found that the magic spell is somehting like
    >db2 set integrity for myschema.mytable immediate checked

    After that statement everything works like a charm.
    DB2 Docs state that:
    "Consider the statement:

    SET INTEGRITY FOR T IMMEDIATE CHECKED
    Situations in which the system will require a full refresh, or will check the whole table
    for integrity (the INCREMENTAL option cannot be specified) are:
    • When new constraints have been added to T itself
    • When a LOAD REPLACE operation against T, it parents, or its underlying tables has taken place
    • When the NOT LOGGED INITIALLY WITH EMPTY TABLE option has been activated after the last integrity check on T, its parents, or its underlying tables
    • The cascading effect of full processing, when any parent of T (or underlying table, if T is a materialized query table or a staging table) has been checked for integrity non-incrementally
    • If the table was in check pending state before migration, full processing is required the first time the table is checked for integrity after migration
    • If the table space containing the table or its parent (or underlying table of a materialized query table or a staging table) has been rolled forward to a point in time, and the table and its parent (or underlying table if the table is a materialized query table or a staging table) reside in different table spaces
    • When T is a materialized query table, and a LOAD REPLACE or LOAD INSERT operation directly into T has taken place after the last refresh"
    But I really dont know what happened with my table.
    Hope this help you out.

    Posted Jan 17 2007, 11:57 AM by Mrojas with no comments
    Filed under: ,
  • Java and Active Directory

       Active Directory is also LDAP. So to integrate with the Active Directory you can use code very similar to that one used with other LDAP servers.

    To connect to the Active Directory you can do something like this:

    import java.util.Hashtable;
    import
    javax.naming.Context;
    import javax.naming.NamingException;
    import javax.naming.directory.DirContext;
    import
    javax.naming.directory.InitialDirContext;

     /**
      * @author mrojas
      */

    public class Test1
    {

          public static void main(String[] args)
          {

                Hashtable environment = new Hashtable();
                //Just change your user here       
               
    String myUser = "myUser";
                //Just change your user password here      

                String myPassword = "myUser"; 

                //Just change your domain name here

                String myDomain = "myDomain";

                //Host name or IP

                String myActiveDirectoryServer = "192.168.0.20";


                environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
                environment.put(Context.PROVIDER_URL, "ldap://" + myActiveDirectoryServer + ":389");
                environment.put(Context.SECURITY_AUTHENTICATION, "simple");
                environment.put(Context.SECURITY_PRINCIPAL, "CN=" + myUser + ",CN=Users,DC=" + myDomain + ",DC=COM");
                environment.put(Context.SECURITY_CREDENTIALS, myPassword);
                try
               
    {
                      DirContext context = new InitialDirContext(environment);
                     
    System.out.println("Lluvia de exitos!!");
               
    }
                catch (NamingException e)
                {
                      e.printStackTrace();
                }
          }
    }




    Posted Jan 10 2007, 04:25 PM by Mrojas with no comments
    Filed under:
  • Creating Excel files from Coldfusion

    I  found a super interesting blog called Busy ColdFusion Developers' Guide to HSSF Features http://www.d-ross.org/index.cfm?objectid=9C65ECEC-508B-E116-6F8A9F878188D7CA

     
    HSSF is part of an open source java project that provides FREE OPEN SOURCE libraries to create Microsoft Office Files like Microsoft Word or Microsoft Excel.

    So I was wondering could it be possible with Coldfusion to use those libraries. Specially now that Coldfusion MX relies heavily in Java. So I found this wonderfull blog that explains it all.

     

    It just went to the HSSF download site: 

     

    http://www.apache.org/dyn/closer.cgi/jakarta/poi/

     

    The project that holds these libraries is called POI.

    When you enter in those links there is a release directory and a bin directory. I downloaded the zip file and you will find three files like: poi-Version-Date.jar; poi-contrib-Version-Date.jar and poi-scratchpad-Version-Date.jar

     

    I downloaded the 2.5.1-final version. I renamed my jars to poi-2.5.1.jar, poi-2.5.1-contrib.jar and poi-2.5.1-scratchpad.jar because my memory cannot hold those complex names for a long time. I installed the library in C:\POI and put them in the Coldfusion Administrator classpath

     

     

     

    And then I created a test file like the following:

     

    Note: I used a recommendation from Cristial Cantrell http://weblogs.macromedia.com/cantrell/archives/2003/06/using_coldfusio.cfm

     

    <cfscript>
        context = getPageContext();
        context.setFlushOutput(false);
        response = context.getResponse().getResponse();
     response.setContentType("application/vnd.ms-excel");
     response.setHeader("Content-Disposition","attachment; filename=unknown.xls");

        out = response.getOutputStream();
    </cfscript>


    <cfset wb = createObject("java","org.apache.poi.hssf.usermodel.HSSFWorkbook").init()/>
    <cfset format = wb.createDataFormat()/>
    <cfset sheet = wb.createSheet("new sheet")/>
    <cfset cellStyle = wb.createCellStyle()/>
    <!--- Take formats from: http://jakarta.apache.org/poi/apidocs/org/apache/poi/hssf/usermodel/HSSFDataFormat.html --->
    <cfset cellStyle.setDataFormat(createObject("java","org.apache.poi.hssf.usermodel.HSSFDataFormat").getBuiltinFormat("0.00"))/>


    <cfloop index = "LoopCount" from = "0" to = "100">
    <!---  Create a row and put some cells in it. Rows are 0 based. --->
    <cfset row = sheet.createRow(javacast("int",LoopCount))/>

    <!---  Create a cell and put a value in it --->
    <cfset cell = row.createCell(0)/>
    <cfset cell.setCellType( 0)/>
    <cfset cell.setCellValue(javacast("int",1))/>

    <!--- Or do it on one line. --->
    <cfset cell2 = row.createCell(1)/>
    <cfset cell2.setCellStyle(cellStyle)/>
    <cfset cell2.setCellValue(javacast("double","1.223452345342"))/>
    <cfset row.createCell(2).setCellValue("This is a string")/>
    <cfset row.createCell(3).setCellValue(true)/>

    </cfloop>


    <cfset wb.write(out)/>
    <cfset wb.write(fileOut)/>
    <cfset fileOut.close()/>
    <cfset out.flush()/>

    Posted Jan 04 2007, 10:55 AM by Mrojas with no comments
    Filed under:
Powered by Community Server (Non-Commercial Edition), by Telligent Systems