Wednesday, September 7, 2011

Apache Clustering

http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html
http://tomcat.apache.org/tomcat-3.2-doc/tomcat-apache-howto.html

Friday, April 22, 2011

Oracle Application Framework - just Basics

Oracle Application Framework (OAF) facilitates consultants (both Technical and Functional) to cater to the daily requirements of their clients by enabling them to personalize, customize, extend and also develop new OAF pages and embed the same back into Oracle Applications. By using OA Framework a developer can:


  • create new OAF pages


  • personalize the pages



  • customize the existing (seeded) pages



  • extend the existing (seeded) pages


  • to meet variuos business needs.
     
    So what's the basic difference between personalization, customization, extension and development

    1. Personalization: With this you can alter or tailor the look and feel of pages e.g. you can change the label of a text box, you can hide or show a component based on the logged in user or at the responsibility level or at site level itself.

    2. Customization: Using this you can add the business logic to the already existing controller code e.g. suppose that you want to add one more validation at the click of some button.

    3. Extension: Extension means that you are using the already existing functionality and also adding some more of yours e.g. you want to add some more where conditions to a seeded View Object (VO) query.

    4. Development: Using development you can create new OAF pages and embed the same to Oracle Apps Instance to cater to the business needs of the clients.

    Now depending upon the layout, complexity and business needs an OAF page can be built up by one or many regions. Region is a part of a page which acts as a container for the items or components. By default the top most level of a page has to be of the type "pageLayout" region type. 
     

    Thursday, April 14, 2011

    MySQL DB Table DESC to Excel Sheet Export

    java code :
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package tabledescription;

    import java.io.FileWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.Statement;

    import java.io.IOException;
    import java.io.File;
    import jxl.Range;
    import jxl.Workbook;
    import jxl.format.UnderlineStyle;
    import jxl.write.Label;
    import jxl.write.WritableCellFormat;
    import jxl.write.WritableFont;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;

    /**
     *
     * @author yogi
     */
    public class Main {

        public static void main(String[] args) throws IOException {
            Connection connection = null;

            WritableWorkbook workbook = Workbook.createWorkbook(new File("D:/my.xls"));
            WritableSheet sheet = workbook.createSheet("mySheet", 0);

            WritableFont arial10font = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.SINGLE, jxl.format.Colour.BROWN);
            WritableCellFormat arial10format = new WritableCellFormat(arial10font);

            WritableFont detailfont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
            WritableCellFormat detailformat = new WritableCellFormat(detailfont);

            WritableFont Headerfont = new WritableFont(WritableFont.ARIAL, 11, WritableFont.BOLD, false, UnderlineStyle.DOUBLE_ACCOUNTING, jxl.format.Colour.BLUE_GREY);
            WritableCellFormat Headerformat = new WritableCellFormat(Headerfont);



            FileWriter fw = new FileWriter(new File("D:/my.csv"));
            fw.write("asdf");
            fw.close();

            try {
    // Load the JDBC driver
                String driverName = "com.mysql.jdbc.Driver"; // MySQL MM JDBC driver
                Class.forName(driverName);

    // Create a connection to the database
                String serverName = "localhost";
                String mydatabase = "mysql";
                String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
                String username = "root";
                String password = "";
                connection = DriverManager.getConnection(url, username, password);

                Statement statment = connection.createStatement();

                ResultSet resultSet = statment.executeQuery("show tables");

                resultSet.next();
                int j = 0;

                while (resultSet.isLast() != true) {

                    Range range = sheet.mergeCells(0, j, 5, 0);

                    Label label = new Label(0, j, resultSet.getString(1), arial10format);
                    sheet.addCell(label);

                    System.out.println("Tables : " + resultSet.getString(1));

                    Statement statment1 = connection.createStatement();
                    ResultSet resultSet1 = statment1.executeQuery("desc " + resultSet.getString(1));

                    ResultSetMetaData RSM1 = resultSet1.getMetaData();

                    /*                Label label8 = new Label(1, j + 1, "Field", Headerformat);
                    sheet.addCell(label8);

                    label8 = new Label(2, j + 1, "Type", Headerformat);
                    sheet.addCell(label8);

                    label8 = new Label(3, j + 1, "Null", Headerformat);
                    sheet.addCell(label8);
                     */
                    resultSet1.next();

                    while (resultSet1.isLast() != true) {
                        int k = j++;
                        for (int i = 1; i <= RSM1.getColumnCount(); i++) {
                            Label label1 = new Label(i, k++, resultSet1.getString(i), detailformat);
                            sheet.addCell(label1);
                            System.out.print(resultSet1.getString(i) + " - ");
                        }
                        System.out.println();
                        resultSet1.next();
                    }
                    resultSet.next();
                }
                workbook.write();
                workbook.close();
            } catch (Exception e) {
                System.out.println("Error : " + e);
            }
        }
    }


    Wednesday, April 13, 2011

    Create Apache,s Projects Structure using ANT

    1 . create bat file
    2. create script file (*.XML)
    3. put the src folder with above 2 file.
    4. put WebPages folder at same location.
    5. Command to create War file : ant -buildfile <buildfilename.xml>
    ------------------------------------------------------------------------------------------

    <?xml version="1.0" ?>
    <project name="AntExample1" default="war" >
       
         <path id="compile.classpath" >
            <fileset dir="WebPages/WEB-INF/lib">
                <include name="*.jar"/>
            </fileset>
        </path>

        <target name="MakeDirectory">
            <mkdir dir="classes"/>
        </target>
      
        <target name="compile" depends="MakeDirectory">
            <javac srcdir="src" destdir="classes" includeantruntime="false" >
            <classpath refid="compile.classpath"/>
            </javac>
        </target>

        <target name="war" depends="compile">
            <war destfile="jarfile\AntExample.war" webxml="WebPages\WEB-INF\web.xml">
                <lib dir="WebPages/WEB-INF/lib"/>
                <classes dir="classes"/>
                <fileset dir="WebPages"/>
            </war>
        </target>
     
    </project>


    Friday, February 18, 2011

    C Program without Main ( or Hidden Main ) - A step Ahead Compiler

    How to write a C program without a main function?. Is it possible to do that. Yes there can be a C program without a main function. Here’s the code of the program without a main function…
     
     
    #include<stdio.h>
    #define decode(s,t,u,m,p,e,d) m##s##u##t
    #define begin decode(a,n,i,m,a,t,e) int begin()
    {
    printf(” hello “);
    }
     
    Does the above program run without the main function? Yes, the above program runs perfectly fine even without a main function. But how, whats the logic behind it? How can we have a C program working without main?
    Here we are using preprocessor directive #define with arguments to give an impression that the program runs without main. But in reality it runs with a hidden main function.
    The ‘##‘ operator is called the token pasting or token merging operator. That is we can merge two or more characters with it.
    NOTE: A Preprocessor is program which processess the source code before compilation.
     
    Look at the 2nd line of program -
    #define decode(s,t,u,m,p,e,d) m##s##u##t
     
    What is the preprocessor doing here. The macro decode(s,t,u,m,p,e,d) is being expanded as “msut” (The ## operator merges m,s,u & t into msut). The logic is when you pass (s,t,u,m,p,e,d) as argument it merges the 4th,1st,3rd & the 2nd characters(tokens).
     
    Now look at the third line of the program -
    #define begin decode(a,n,i,m,a,t,e)
     
    Here the preprocessor replaces the macro “begin” with the expansion decode(a,n,i,m,a,t,e). According to the macro definition in the previous line the argument must be expanded so that the 4th,1st,3rd & the 2nd characters must be merged. In the argument (a,n,i,m,a,t,e) 4th,1st,3rd & the 2nd characters are ‘m’,'a’,'i’ & ‘n’.
    So the third line “int begin” is replaced by “int main” by the preprocessor before the program is passed on for the compiler. That’s it…
    The bottom line is there can never exist a C program without a main function. Here we are just playing a gimmick that makes us beleive the program runs without main function, but actually there exists a hidden main function in the program. Here we are using the proprocessor directive to intelligently replace the word begin” by “main”. In simple words int begin=int main.

    Wednesday, February 2, 2011

    JSF (Java Server Faces)

    What is JSF?
    JSF is new standard framework, developed through Java Community Process (JCP), that makes it easy to build user interfaces for java web applications  by assembling reusable components in a page. You can think of  JSF framework as a toolbox  that is full of  ready to use components where you can quickly  and easily add and reuse  these components many times in a page and capture events generated by actions on these components. So JSF applications are event driven. You typically embed components in a jsp page using custom tags defined by JSF technology and use the framework to handle navigation from one page to another. Components can be nested within another component , for example, input box, button in a form.
    JSF is based on well established Model-View-Controller (MVC) design pattern. Applications developed using JSF frameworks are well designed and easy to maintain then any other applications developed in JSP and Servlets.
    JSF eases the development of web applications based on Java technologies. Here are some of benefits of using JSF:
    • JSF provides standard, reusable components for creating user interfaces for web applications.
    • JSF provides many tag libraries for accessing and manipulating the components.
    • It automatically saves the form data and repopulates the form when it is displayed at client side.
    • JSF encapsulates the event handling and component rendering logic from programmers, programmers just use the custom components.
    • JSF is a specification and vendors can develop the implementations for JSF.
    • There are many GUIs available these days to simplify the development of web based application based on JSF framework.
    JSF Components
    JSF  includes mainly:
    1. Set of APIs to represent and manage state of components that helps server side validation, event handling, page navigation, data conversion etc.
    2. JSP custom tag library to create UI components in a view page.
    The UI (user interface) created using JSF technology runs on server and  output is shown to the client. Goal of JSF  is to create web applications faster and easier. Developers can focus on UI components, events handling, backing beans and their interactions rather than request, response and markup. JSF hides complexities to enable developers to focus on their own specific work.

    Disqus for yogi's talk

    comments powered by Disqus