KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > OutOfMemoryError

java.lang
Class OutOfMemoryError

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Error
          extended by java.lang.VirtualMachineError
              extended by java.lang.OutOfMemoryError
All Implemented Interfaces:
Serializable
See Also:
Top Examples, Source Code

public OutOfMemoryError()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public OutOfMemoryError(String s)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1204]Servlet that reads DB and parse XML
By mkader { at } sessolutions { dot } com on 2004/12/20 16:26:40  Rate
package com.tam.reports; 
  
  
 import java.sql.*; 
 import java.io.*; 
 import java.util.*; 
 import javax.servlet.ServletException; 
 import javax.servlet.http.*; 
 import com.tam.ses.LoadProperties; 
 import com.tam.ses.XmlParser; 
  
  
 public class TeamTimeSheetReport extends HttpServlet 
  {  
   XmlParser    xmlParser    =  new XmlParser (  ) ; 
   LoadProperties   lpDatabase    =  new LoadProperties (  ) ; 
  
  
   String       parserOutput  =  ""; 
   String       xmlOutput     =  ""; 
  
  
   public void doGet  ( HttpServletRequest request,HttpServletResponse response )  throws ServletException, IOException 
    {  
     doPost ( request,response ) ; 
    }  
  
  
   public void doPost  ( HttpServletRequest request,HttpServletResponse response )  throws ServletException, IOException 
    {  
     response.setContentType ( "text/html; charset=UTF-8" ) ; 
  
  
     String       sAccountId    =  ""; 
  
  
     sAccountId  =  ( request.getParameter ( "aid" ) ==null?"":request.getParameter ( "aid" )  ) ; 
     if  ( sAccountId.equals ( "ALL" )  )  
      {  
       ALLEmployeeTimeSheetReport ( request,response ) ; 
      }  
     else 
      {  
       EmployeeTimeSheetReport ( request,response,sAccountId ) ; 
      }  
    }  
   private void ALLEmployeeTimeSheetReport ( HttpServletRequest request,HttpServletResponse response )  throws ServletException, IOException 
    {  
  
  
     PrintWriter   out       =   response.getWriter (  ) ; 
     String       startDate     =  ""; 
     String       endDate     =  ""; 
     startDate  =  ( request.getParameter ( "startDate" ) ==null?"":request.getParameter ( "startDate" )  ) ; 
     endDate    =  ( request.getParameter ( "endDate" ) ==null?"":request.getParameter ( "endDate" )  ) ; 
     if  ( ! (  ( endDate.length (  )  > 0 )  &&  ( startDate.length (  )  > 0 )  )  )  
      {  
       parserOutput  =    ( String ) xmlParser.XmlParser ( request,response,"sesXMLLogin","fiscalstartdate.xsl","","","","" ) ; 
       startDate     =   parserOutput.substring ( 40, parserOutput.length (  )  ) ; 
       parserOutput  =    ( String ) xmlParser.XmlParser ( request,response,"sesXMLLogin","fiscalenddate.xsl","","","","" ) ; 
       endDate     =   parserOutput.substring ( 40, parserOutput.length (  )  ) ; 
      }  
     try 
      {  
       lpDatabase.LoadProperties (  ) ; 
       Class.forName ( lpDatabase.DRIVER ) ; 
       Connection   conReport = DriverManager.getConnection ( lpDatabase.DSN,lpDatabase.USER,lpDatabase.PASSWORD ) ; 
       CallableStatement csReport; 
       csReport = conReport.prepareCall ( " { call rptTeamTimeSheetALLEmployee ( ?,? )  } " ) ; 
       csReport.setString  ( 1,startDate ) ; 
       csReport.setString  ( 2,endDate ) ; 
       csReport.execute (  ) ; 
       ResultSet   rs = csReport.getResultSet (  ) ; 
       while  ( rs.next (  )  )  
        {  
         xmlOutput = xmlOutput+rs.getString ( "XML_F52E2B61-18A1-11d1-B105-00805F49916B" ) ; 
        }  
       rs.close (  ) ; 
       conReport.close (  ) ; 
      }  
     catch  ( Exception e )  
      {  
       System.out.println ( " ***** TeamTimeSheetReport.ALLEmployeeTimeSheetReport Error ***** " + e ) ; 
      }  
     out.println ( xmlParser.XmlParser ( xmlOutput,"reports/rptTeamTimeSheet.xsl","","","","","","" )  ) ; 
    }  
  
  
   private void EmployeeTimeSheetReport ( HttpServletRequest request,HttpServletResponse response, String sAccountId )  throws ServletException, IOException 
    {  
     PrintWriter   out       =   response.getWriter (  ) ; 
     int       accountid; 
  
  
     if  ( ! ( sAccountId.length (  )  > 0 )  )  
      {  
       parserOutput  =    ( String ) xmlParser.XmlParser ( request,response,"sesXMLLogin","employeeID.xsl","","","","" ) ; 
       accountid     =   Integer.parseInt ( parserOutput.substring ( 40, parserOutput.length (  )  )  ) ; 
      }  
     else 
      {  
       accountid     =   Integer.parseInt ( sAccountId ) ; 
      }  
  
  
     String       startDate     =  ""; 
     String       endDate     =  ""; 
     startDate  =  ( request.getParameter ( "startDate" ) ==null?"":request.getParameter ( "startDate" )  ) ; 
         endDate    =  ( request.getParameter ( "endDate" ) ==null?"":request.getParameter ( "endDate" )  ) ; 
         if  ( ! (  ( endDate.length (  )  > 0 )  &&  ( startDate.length (  )  > 0 )  )  )  
          {  
       parserOutput  =    ( String ) xmlParser.XmlParser ( request,response,"sesXMLLogin","fiscalstartdate.xsl","","","","" ) ; 
       startDate     =   parserOutput.substring ( 40, parserOutput.length (  )  ) ; 
       parserOutput  =    ( String ) xmlParser.XmlParser ( request,response,"sesXMLLogin","fiscalenddate.xsl","","","","" ) ; 
       endDate     =   parserOutput.substring ( 40, parserOutput.length (  )  ) ; 
      }  
     try 
      {  
       lpDatabase.LoadProperties (  ) ; 
       Class.forName ( lpDatabase.DRIVER ) ; 
       Connection   conReport = DriverManager.getConnection ( lpDatabase.DSN,lpDatabase.USER,lpDatabase.PASSWORD ) ; 
       CallableStatement csReport; 
       csReport = conReport.prepareCall ( " { call rptTeamTimeSheet ( ?,?,? )  } " ) ; 
       csReport.setInt  ( 1,accountid ) ; 
       csReport.setString  ( 2,startDate ) ; 
       csReport.setString  ( 3,endDate ) ; 
       csReport.execute (  ) ; 
       ResultSet   rs = csReport.getResultSet (  ) ; 
       while  ( rs.next (  )  )  
        {  
         xmlOutput = xmlOutput+rs.getString ( "XML_F52E2B61-18A1-11d1-B105-00805F49916B" ) ; 
        }  
       rs.close (  ) ; 
       conReport.close (  ) ; 
      }  
     catch  ( Exception e )  
      {  
       System.out.println ( " ***** TeamTimeSheetReport.EmployeeTimeSheetReport Error ***** " + e ) ; 
      }  
     out.println ( xmlParser.XmlParser ( xmlOutput,"reports/rptTeamTimeSheet.xsl","","","","","","" )  ) ; 
    }  
  }  
 


[1977]
By nityananda { dot } cs { at } gmail { dot } com on 2008/08/23 14:48:23  Rate
import java.sql.*;  
  import java.io.*;  
  import java.util.*;  
  import javax.servlet.ServletException;  
  import javax.servlet.http.*;  
  import com.tam.ses.LoadProperties;  
  import com.tam.ses.XmlParser;  
    
    
  public class TeamTimeSheetReport extends HttpServlet  
    {    
    XmlParser xmlParser = new XmlParser  (    )  ;  
    LoadProperties lpDatabase = new LoadProperties  (    )  ;  
    
    
    String parserOutput = "";  
    String xmlOutput = "";  
    
    
 // public void doGet   (  HttpServletRequest request,HttpServletResponse response  )   throws ServletException, IOException  
 //     {    
 // doPost  (  request,response  )  ;  
 //     }    
 //   
    
    public void doGet   (  HttpServletRequest request,HttpServletResponse response  )   throws ServletException, IOException  
      {    
      response.setContentType  (  "text/html; charset=UTF-8"  )  ;  
    
    
      String sAccountId = "";  
    
    
      sAccountId =   (  request.getParameter  (  "aid"  )  ==null?"":request.getParameter  (  "aid"  )    )  ;  
      if   (  sAccountId.equals  (  "ALL"  )    )    
        {    
        ALLEmployeeTimeSheetReport  (  request,response  )  ;  
        }    
      else  
        {    
        EmployeeTimeSheetReport  (  request,response,sAccountId  )  ;  
        }    
      }    
    private void ALLEmployeeTimeSheetReport  (  HttpServletRequest request,HttpServletResponse response  )   throws ServletException, IOException  
      {    
    
    
      PrintWriter out = response.getWriter  (    )  ;  
      String startDate = "";  
      String endDate = "";  
      startDate =   (  request.getParameter  (  "startDate"  )  ==null?"":request.getParameter  (  "startDate"  )    )  ;  
      endDate =   (  request.getParameter  (  "endDate"  )  ==null?"":request.getParameter  (  "endDate"  )    )  ;  
      if   (  !  (    (  endDate.length  (    )    >  0  )   &&   (  startDate.length  (    )    >  0  )    )    )    
        {    
        parserOutput =     (  String  )  xmlParser.XmlParser  (  request,response,"sesXMLLogin","fiscalstartdate.xsl","","","",""  )  ;  
        startDate = parserOutput.substring  (  40, parserOutput.length  (    )    )  ;  
        parserOutput =     (  String  )  xmlParser.XmlParser  (  request,response,"sesXMLLogin","fiscalenddate.xsl","","","",""  )  ;  
        endDate = parserOutput.substring  (  40, parserOutput.length  (    )    )  ;  
        }    
      try  
        {    
        lpDatabase.LoadProperties  (    )  ;  
        Class.forName  (  lpDatabase.DRIVER  )  ;  
        Connection conReport = DriverManager.getConnection  (  lpDatabase.DSN,lpDatabase.USER,lpDatabase.PASSWORD  )  ;  
        CallableStatement csReport;  
        csReport = conReport.prepareCall  (  "  {  call rptTeamTimeSheetALLEmployee  (  ?,?  )    }  "  )  ;  
        csReport.setString   (  1,startDate  )  ;  
        csReport.setString   (  2,endDate  )  ;  
        csReport.execute  (    )  ;  
        ResultSet rs = csReport.getResultSet  (    )  ;  
        while   (  rs.next  (    )    )    
          {    
          xmlOutput = xmlOutput+rs.getString  (  "XML_F52E2B61-18A1-11d1-B105-00805F49916B"  )  ;  
          }    
        rs.close  (    )  ;  
        conReport.close  (    )  ;  
        }    
      catch   (  Exception e  )    
        {    
        System.out.println  (  " ***** TeamTimeSheetReport.ALLEmployeeTimeSheetReport Error ***** " + e  )  ;  
        }    
      out.println  (  xmlParser.XmlParser  (  xmlOutput,"reports/rptTeamTimeSheet.xsl","","","","","",""  )    )  ;  
      }    
    
    
    private void EmployeeTimeSheetReport  (  HttpServletRequest request,HttpServletResponse response, String sAccountId  )   throws ServletException, IOException  
      {    
      PrintWriter out = response.getWriter  (    )  ;  
      int  accountid;  
    
    
      if   (  !  (  sAccountId.length  (    )    >  0  )    )    
        {    
        parserOutput =     (  String  )  xmlParser.XmlParser  (  request,response,"sesXMLLogin","employeeID.xsl","","","",""  )  ;  
        accountid = Integer.parseInt  (  parserOutput.substring  (  40, parserOutput.length  (    )    )    )  ;  
        }    
      else  
        {    
        accountid = Integer.parseInt  (  sAccountId  )  ;  
        }    
    
    
      String startDate = "";  
      String endDate = "";  
      startDate =   (  request.getParameter  (  "startDate"  )  ==null?"":request.getParameter  (  "startDate"  )    )  ;  
          endDate =   (  request.getParameter  (  "endDate"  )  ==null?"":request.getParameter  (  "endDate"  )    )  ;  
          if   (  !  (    (  endDate.length  (    )    >  0  )   &&   (  startDate.length  (    )    >  0  )    )    )    
            {    
        parserOutput =     (  String  )  xmlParser.XmlParser  (  request,response,"sesXMLLogin","fiscalstartdate.xsl","","","",""  )  ;  
        startDate = parserOutput.substring  (  40, parserOutput.length  (    )    )  ;  
        parserOutput =     (  String  )  xmlParser.XmlParser  (  request,response,"sesXMLLogin","fiscalenddate.xsl","","","",""  )  ;  
        endDate = parserOutput.substring  (  40, parserOutput.length  (    )    )  ;  
        }    
      try  
        {    
        lpDatabase.LoadProperties  (    )  ;  
        Class.forName  (  lpDatabase.DRIVER  )  ;  
        Connection conReport = DriverManager.getConnection  (  lpDatabase.DSN,lpDatabase.USER,lpDatabase.PASSWORD  )  ;  
        CallableStatement csReport;  
        csReport = conReport.prepareCall  (  "  {  call rptTeamTimeSheet  (  ?,?,?  )    }  "  )  ;  
        csReport.setInt   (  1,accountid  )  ;  
        csReport.setString   (  2,startDate  )  ;  
        csReport.setString   (  3,endDate  )  ;  
        csReport.execute  (    )  ;  
        ResultSet rs = csReport.getResultSet  (    )  ;  
        while   (  rs.next  (    )    )    
          {    
          xmlOutput = xmlOutput+rs.getString  (  "XML_F52E2B61-18A1-11d1-B105-00805F49916B"  )  ;  
          }    
        rs.close  (    )  ;  
        conReport.close  (    )  ;  
        }    
      catch   (  Exception e  )    
        {    
        System.out.println  (  " ***** TeamTimeSheetReport.EmployeeTimeSheetReport Error ***** " + e  )  ;  
        }    
      out.println  (  xmlParser.XmlParser  (  xmlOutput,"reports/rptTeamTimeSheet.xsl","","","","","",""  )    )  ;  
      }    
    }   

Popular Tags