BO Data Services - Reading from excel file and writing to SQL Server Table

Hi,
I would like to read data from an excel file and write it to a SQL Server Data base table without making any transformations using Data Services. I have created an excel file format as source and created target table in SQL Server. The data flow will just have source and target. I am not sure how to map the columns between source and target. Appreciate your quick help in providing a detailed steps of mapping.
Regards,
Ramesh

Ramesh,
were you able to get this to work? if not, let me know and I can help you out with it.
Lynne

Similar Messages

  • Loop Through Excel Files and Load into SQL Server Table

    I'm following the example here.
    https://www.youtube.com/watch?v=_B83CPqX-N4
    I'm pretty sure I did all the steps, but for some reason my project is not running.  I'm thinking there is a 32-bit or 64-bit issue lurking in here somewhere.
    Here's my error message.
    SSIS package "C:\Users\Ryan\Documents\Visual Studio 2010\Projects\Loop through Multiple Excel sheets and load them into a SQL Table\Integration Services Project1\Package.dtsx" starting.
    Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
    Error: 0xC0209303 at Package, Connection manager "Excel Connection Manager": The requested OLE DB provider Microsoft.ACE.OLEDB.12.0 is not registered. If the 64-bit driver is not installed, run the package in 32-bit mode. Error code: 0x00000000.
    An OLE DB record is available.  Source: "Microsoft OLE DB Service Components"  Hresult: 0x80040154  Description: "Class not registered".
    Error: 0xC001002B at Package, Connection manager "Excel Connection Manager": The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
    For more information, see http://go.microsoft.com/fwlink/?LinkId=219816
    Error: 0xC020801C at Data Flow Task, Excel Source [2]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0209303. 
    There may be error messages posted before this with more information on why the AcquireConnection method call failed.
    Error: 0xC0047017 at Data Flow Task, SSIS.Pipeline: Excel Source failed validation and returned error code 0xC020801C.
    Error: 0xC004700C at Data Flow Task, SSIS.Pipeline: One or more component failed validation.
    Error: 0xC0024107 at Data Flow Task: There were errors during task validation.
    SSIS package "C:\Users\Ryan\Documents\Visual Studio 2010\Projects\Loop through Multiple Excel sheets and load them into a SQL Table\Integration Services Project1\Package.dtsx" finished: Failure.
    The program '[5392] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).
    I have 32-bit Excel and 64-bit SQL Server.  Is that the issue?  Can someone tell me what's wrong here?
    Thanks!!
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Sa-weeettttttt!!  Thanks.  I figured that's what it was.  For the benefit of others, this link shows you exactly how to make the modification recommended above.
    http://help.pragmaticworks.com/dtsxchange/scr/FAQ%20-%20How%20to%20run%20SSIS%20Packages%20using%2032bit%20drivers%20on%2064bit%20machine.htm
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • How to  read from excel file and write it using implicit jsp out object

    our code is as below:Please give us proper solution.
    we are reading from Excel file and writing in dynamicaly generated Excel file.it is writing but not as original excel sheet.we are using response.setContentType and response.setHeader for generating pop up for saveing the original file in to dynamically generated Excel file.
    <%@ page contentType="application/vnd.ms-excel" %>
    <%     
         //String dLoadFile = (String)request.getParameter("jspname1");
         String dLoadFile = "c:/purge_trns_nav.xls" ;
         File f = new File(dLoadFile);
         //set the content type(can be excel/word/powerpoint etc..)
         response.setContentType ("application/msexcel");
         //get the file name
         String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
         //set the header and also the Name by which user will be prompted to save
         response.setHeader ("Content-Disposition", "attachment;     filename="+name);
         //OPen an input stream to the file and post the file contents thru the
         //servlet output stream to the client m/c
              FileInputStream in = new FileInputStream(f);
              //ServletOutputStream outs = response.getOutputStream();
              int bit = 10;
              int i = 0;
              try {
                        while (bit >= 0) {
                        bit = in.read();
                        out.write(bit) ;
    } catch (IOException ioe) { ioe.printStackTrace(System.out); }
              out.flush();
    out.close();
    in.close();     
    %>

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

  • Read from xls file and put it in a table

    Hi,
    I've an xls file while is having 8 cells with some thousands of rows. i've to write a procedure to read that file and put it in a table(each cell as each column). pls help me how to proceed. i'm using oracle 9i
    Regards
    Abdul Muthalef

    as Gasparotto said, copy the csv file to the database server.
    create a directory object on the database.
    create directory dir_temp as 'e:\mydir'
    grant read, write on directory dir_Temp to <user>
    and then map this csv file to the external table using the below syntax.
    CREATE TABLE tab_hierarchy
    node_id          NUMBER,
    parent_id     NUMBER,
    description      VARCHAR2(255)
    ORGANIZATIOn EXTERNAL
         TYPE ORACLE_LOADER
         DEFAULT DIRECTORY dir_temp
         ACCESS PARAMETERS
         records delimited by newline
         fields terminated by ','
         (node_id,parent_id,description)
         LOCATION ('tree.csv')
    PARALLEL
    REJECT LIMIT UNLIMITED;in the above code, replace the filename under the LOCATION with your csv file name.
    now you should be just able to do select on this table and insert to the other main tbale.

  • Error in reading from excel file

    hi,
    I have written a program which reads from excel file
    and based on the value of the column i have to do something.
    Everything is fine but when i run it, it produces an error message
    Exception: For input string: "851.0"
    the value 851.0 is acually the value of the first column.
    Here is the code and i hope someone can help me to find the solution
    try{
                               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                               Connection con = DriverManager.getConnection( "jdbc:odbc:exceltest" );
                               Statement st = con.createStatement();
                               ResultSet rs = st.executeQuery( "Select * from [Sheet1$] " );
                               ResultSetMetaData rsmd = rs.getMetaData();
                               int numberOfColumns = rsmd.getColumnCount();
                               while (rs.next()) {
                                            for (int i = 1; i <= numberOfColumns; i++) {
                                                 if(i==1){
                                                            String columnValue1 = rs.getString(i);
                                                            custNo =Integer.parseInt(columnValue1);
                                                           // System.out.println(columnValue1);     
                                                            found=search(custNo);
                                                            if (found==false)
                                                                 insert(custNo);
                                                            System.out.println(columnValue1);     
                                                 else if (i == numberOfColumns && found==false)
                                                           String columnValue = rs.getString(i);
                                                           if(columnValue=="a")
                                                                incrementCusta();
                                                           else if (columnValue=="b")
                                                                incrementCustB();
                                                           else if(columnValue=="c")
                                                                incrementCustc();
                                                           else if(columnValue=="d")
                                                                incrementCustId();
                                            System.out.println("");     
                                       st.close();
                                       con.close();
                                      } catch(Exception ex) {
                                           System.err.print("Exception: ");
                                           System.err.println(ex.getMessage());
                                 }

    Maybe 851.0 is float value, not string.
    Try Object columnValue1 =
    rs.getObject(i); instead of String
    columnValue1 = rs.getString(i);
    You are absolutely right i actually change the line
    custNo =Integer.parseInt(columnValue1);
    into
    custNo =Double.parseDouble(columnValue1);
    Thanks alot :)

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • Reading the data from excel file which is in application server.

    Hi,
    Iam trying to read the data from excel file which is in application server.
    I tried using the function module ALSM_EXCEL_TO_INTERNAL_TABLE. But it didn't work.
    I tried just reading using open data set and read data set it is giving junk characters.
    Please suggest me if you have any solution.
    Best Regards,
    Brahma Reddy

    Hi Narendra,
    Please see the below code I have written
    OPEN DATASET pa_sfile for INPUT in text mode ENCODING  DEFAULT MESSAGE wf_mess.
    CHECK sy-subrc = 0.
    DO.
    READ DATASET pa_sfile INTO wf_string.
    IF sy-subrc <> 0.
    EXIT.
    else.
    split wf_string at wl_# into wf_field1 wf_field2 wa_upload-field3
    wa_upload-field4 wa_upload-field5 wa_upload-field6 wa_upload-field7 wa_upload-field8
    wa_upload-field9 wa_upload-field10 wa_upload-field11 wa_upload-field12 wa_upload-field13
    wa_upload-field14 wa_upload-field15 wa_upload-field16 wa_upload-field17 wa_upload-field18
    wa_upload-field19 wa_upload-field20 wa_upload-field21 wa_upload-field22 wa_upload-field23
    wa_upload-field24 wa_upload-field25 wa_upload-field26 wa_upload-field27 wa_upload-field28
    wa_upload-field29 wa_upload-field30 wa_upload-field31 wa_upload-field32 wa_upload-field33
    wa_upload-field34 wa_upload-field35 wa_upload-field36 .
    wa_upload-field1 = wf_field1.
    wa_upload-field2 = wf_field2.
    append wa_upload to int_upload.
    clear wa_upload.
    ENDIF.
    ENDDO.
    CLOSE DATASET pa_sfile.
    Please note Iam using ECC5.0 and it is not allowing me to declare wl_# as x as in your code.
    Also if Iam using text mode I should use extension encoding etc.( Where as not in your case).
    Please suggest me any other way.
    Thanks for your help,
    Brahma Reddy

  • Store data in mysql after reading from excel files

    i am trying to make o program where i will read the data from excel files and i will store them in a database. I am using eclipse as editor and mySQL. I am using APACHE POI to read the excel files and JDBC for the connection. The excel files have the structure as shown below:
    ID NAME SALARY STREET
    321 TIM 1254 14 avenue
    121 PAUL 1265 28h oktovriou
    432 NICK 4521 papaflessa
    I have of course plenty of such files which contains many more rows and columns. The purpose of my program is to read the data, create table named as the name of the excel file and the fields of each table to be the first rows of the excel file. Afterwards the values will be the rest data of the excel file. In the code below i have managed to read them, show the data in the console. Afterwrds i am trying to call a database with JDBC but there i have problem when i create the table.
    try
    String[] allFields;
    String createTableStr = "CREATE TABLE" + createTableStr
    + "(" + org.apache.commons.lang3.StringUtils.join(allFields,
    ",") + ")";
    Could anyone help me?
    Thank you in advance!:)
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.commons.lang3.StringUtils;
    import org.apache.poi.ss.usermodel.Cell;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class exam1 {
    @SuppressWarnings({ "unchecked", "unchecked" })
    static void main (String[] args) throws Exception {
    String filename = "C:\\Users\\Efi\\Documents\\test5.xls";
    List sheetData = new ArrayList();
    FileInputStream fis = null;
    try {
    fis = new FileInputStream(filename);
    HSSFWorkbook workbook = new HSSFWorkbook(fis);
    HSSFSheet sheet = workbook.getSheetAt(0);
    Iterator rows = sheet.rowIterator();
    while (rows.hasNext()) {
    HSSFRow row = (HSSFRow) rows.next();
    Iterator cells = row.cellIterator();
    List data = new ArrayList();
    while (cells.hasNext()) {
    HSSFCell cell = (HSSFCell) cells.next();
    data.add(cell);
    sheetData.add(data);
    } catch (IOException e) {
    e.printStackTrace();
    } finally {
    if (fis != null) {
    fis.close();
    showExcelData(sheetData);
    @SuppressWarnings("unused")
    HashMap<String, String> tableFields = new HashMap();
    for (int i=0; i<sheetData.size();i++){
    List list = (List) sheetData.get(i);
    for (int j=0; j<list.size(); j++){
    Cell cell = (Cell) list.get(j);
    if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
    System.out.print(cell.getNumericCellValue());
    }else if(cell.getCellType()==Cell.CELL_TYPE_STRING) {
    System.out.print(cell.getRichStringCellValue());
    } else if(cell.getCellType()==Cell.CELL_TYPE_BOOLEAN) {
    System.out.print(cell.getBooleanCellValue());
    if (j < list.size() - 1) {
    System.out.print(", ");
    private static void showExcelData(List sheetData) {
    @SuppressWarnings("unchecked")
    private HashMap parseExcelData (List sheetData){
    HashMap<String,Integer> tableFields = new HashMap();
    List list = (List) sheetData.get(0);
    for (int j=0; j<list.size(); j++){
    Cell cell=(Cell) list.get(j);
    tableFields.put(cell.getStringCellValue(),cell.getCellType());
    return tableFields;
    @SuppressWarnings({ "unchecked", "unchecked", "unchecked", "unchecked", "unused" })
    private String getCreateTable(String tablename, HashMap<String, Integer> tableFields){
    Iterator iter = tableFields.keySet().iterator();
    String str="";
    String[] allFields = new String[tableFields.size()];
    int i = 0;
    while (iter.hasNext()){
    String fieldName = (String) iter.next();
    Integer fieldType=(Integer)tableFields.get(fieldName);
    switch (fieldType){
    case Cell.CELL_TYPE_NUMERIC:
    str=fieldName + "INTEGER";
    break;
    case Cell.CELL_TYPE_STRING:
    str= fieldName + "VARCHAR(255)";
    break;
    case Cell.CELL_TYPE_BOOLEAN:
    str=fieldName + "INTEGER";
    break;
    allFields[i++]= str;
    return str;
    public Connection getConnection() throws SQLException {
    try {
    Class.forName("com.mysql.jdbc.Driver");
    Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/kainourgia","root", "root");
    Statement stmt = con.createStatement();
    try
    System.out.println( "Use the database..." );
    stmt.executeUpdate( "USE kainourgia;" );
    catch( SQLException e )
    System.out.println( "SQLException: " + e.getMessage() );
    System.out.println( "SQLState: " + e.getSQLState() );
    System.out.println( "VendorError: " + e.getErrorCode() );
    try
    String[] allFields;
    String createTableStr = "CREATE TABLE" + createTableStr
    + "(" + org.apache.commons.lang3.StringUtils.join(allFields,
    *",") + ")";*
    System.out.println( "Create a new table in the database" );
    stmt.executeUpdate( createTableStr );
    catch( SQLException e )
    System.out.println( "SQLException: " + e.getMessage() );
    System.out.println( "SQLState: " + e.getSQLState() );
    System.out.println( "VendorError: " + e.getErrorCode() );
    catch( Exception e )
    System.out.println( ((SQLException) e).getSQLState() );
    System.out.println( e.getMessage() );
    e.printStackTrace();
    return null;
    }

    Please don't multipost! Also crossposted: http://www.java-forums.org/jdbc/71612-store-data-mysql-after-reading-excel-files.html
    Mod: I'm locking this thread.

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • Read an excel file and convert to a 1-D array of long, 32-bit integer?

    My vi right now reads an column of numbers as a 1-D array, but I need to input the numbers manually, and for what I'm trying to do, there could be anywhere between 100 to 500 numbers to input. I want the vi to be able to read the excel file and use that column of numbers for the rest, which the data type is long (32-bit integer).
    I have an example vi that is able to get excel values, but the output data type is double (64-bit real).
    I need to either be able to convert double(64-bit real) data to long (32-bit integer), or find another way to get the values from the excel file.

    Just to expand on what GerdW is saying.  There are many programs that hold exclusive access to a file.  So if a file is opened in Excel, the LabVIEW cannot access the file.
    What is the exact error code?  Different error codes will point to different issues.
    Make sure the csv file is exactly where you think it is and LabVIEW is pointing to the right place.  (I'm just going through stupid things I have done)
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • .exe reading from Excel files

    Hi everybody,
    I know similar questions have been asked lots of times but while searching the forum didn't find an anwer to my problem.
    I created an exe file (using exe4j) of a java application which reads form Excel files. Although it works when I run it from my editor, when running the exe file it cant find the Excel file. More specifically I have this error:
    "java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
    In order to read from excel files I use POI. I used it so as not to use ODBC driver and make it possible to run in every computer. When adding the driver, the exe works.Do you know a way to make it work without having to install the Driver?
    Thanks in Advance

    You need database drivers to read excel spread sheets?
    Also, why did you make it an exe? just jar it and be done with it.

  • How to update Ztable from Excel file and how to check conditions ,

    HI this uday,
    pls help me how can i update Ztable from Excel file and how to check conditions .
    regards
    uday
    Moderator message: please (re)search yourself before asking.
    Edited by: Thomas Zloch on Jul 13, 2010 12:00 PM

    Hi
    Use Fm : ALSM_EXCEL_TO_INTERNAL_TABLE.
    L_INTERN : internal table with your fields .
    make sure that the fields in the Excel should be formatted (as numeric , characher ) depending upon the data types .
    LOOP AT L_INTERN INTO WA_LINTERN .
            MOVE WA_LINTERN-COL TO L_INDEX.
            ASSIGN COMPONENT  L_INDEX OF STRUCTURE WA_INREC TO <FS> .
            IF SY-SUBRC = 0.
              MOVE WA_LINTERN-VALUE TO <FS>.
            ENDIF.
            AT END OF  ROW .                                    "#EC *
              APPEND WA_INREC TO IT_DATA.  "
              CLEAR WA_INREC.
            ENDAT.
         ENDLOOP.
    Regards
    Swapnil

  • Read a excel file and split its sheets to seperate file ?

    Dear all :
    How to split a excel file into several file, each have one sheet.my code is as below,thanks:
    import org.apache.poi.hssf.usermodel.*;
    import java.io.*;
    import java.util.*;
    import org.apache.poi.poifs.filesystem.*;
    public class Extractxls {
    public static void main(String[] args) throws Exception
    try {
    POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(args[0]));
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    int sheetCount = wb.getNumberOfSheets();
    System.out.println(sheetCount);
    try {
         while(sheetCount > 0) {
         sheetCount--;
         HSSFWorkbook wb1 = new HSSFWorkbook();
         HSSFSheet s = wb1.createSheet();
         String sheetName = wb.getSheetName(sheetCount);
         HSSFSheet sheet = wb.getSheet(sheetName);
    //     HSSFSheet sheet = wb.getSheetAt(sheetCount);
         System.out.println(sheet.toString());
         s = sheet;
    FileOutputStream fileOut = new FileOutputStream("atest" + sheetCount + ".xls");
    wb.write(fileOut);
    fileOut.close();
    } catch (Exception e) {
         System.err.println("Error: " + e.getMessage());
    } catch (Exception e) { e.toString();}

    The HSSFWorkbook class is part of the POI project:
    http://jakarta.apache.org/poi/
    Regards,
    Dave Gilbert
    JFreeChart Project Leader
    I understand poi porject, my problem is that POI can not read a excel file and split its sheets into seperate file (each have one sheet) ?Does any one know how to do it.

  • Problem in reading no. of files and writing into a single file

    Hi,
    Iam with Problem in reading no. of files and writing into a single file....
    Iam reading no. of files stored in local directory.......
    Iam able to read and print the data in files successfully....but while writing..only first file is being written...and the next files are not written in my output file...
    plz tell me my mistake....I hope Iam doing some mistake while writing into file...PLz help.....
    Basically my code structure is like this....
    import java.io.*;
    import java.util.regex.*;
    import java.util.*;
    import java.text.*;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    class Writing {
    public static void main(String args[]) throws Exception {
              FileOutputStream fileOut = new FileOutputStream("ServerResult.xls"); //my output file
              int counter = 1;
              File dir = new File("C:/Perform/ServerLogs");
              String[] children = dir.list();
              if( children == null)
                   System.out.println("The Directory mentioned does not exist");
              else {
                   for (int fileNo = 0; fileNo < children.length; fileNo++ ) {        //Files iteration starts
                        String filename = children[fileNo];
              File logFile = new File(filename);
    FileReader logFileReader = new FileReader(logFile);
    BufferedReader logReader = new BufferedReader(logFileReader);
    StringBuffer sBuf = new StringBuffer(5000);
              HSSFWorkbook wb = new HSSFWorkbook();          
              HSSFSheet sheet = wb.createSheet();
              HSSFRow rowTitle;
              HSSFRow rowReq;
              HSSFRow rowRes;
    String aLine = null;
    boolean skip = false;
    boolean readed = false;
    boolean initReq = false;
              boolean flag = false;
    long requestTime = 0;
    long responseTime = 0;
    long recdTime = 0;
    long sentTime = 0;
              long hasTime = 0;
              long presentTime = 0;
              int hasCalls = 0;
    Pattern startMessage = Pattern.compile("^<MESSAGE.*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern requestMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"RequestMsg.\".*ID=\".*_"+args[0]+"\".*<ActName>(.*)</ActName>.*", Pattern.DOTALL);
    Pattern requestMessage1 = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"RequestMsg.\".*ID=\".*_"+args[0]+"\".*<Svc id=\"(.*)\">.*", Pattern.DOTALL);
    Pattern responseMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern initMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"HostConnInit\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern initResMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\"null\".*", Pattern.DOTALL);
    Pattern initResIDMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\"null\".*<IATA>"+args[0]+"</IATA>.*", Pattern.DOTALL);
              Pattern sentMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"DCMsgSentInfo\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
              Pattern rcvdMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"DCMsgRcvdInfo\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    DecimalFormat dcf = new DecimalFormat("########.##");
    String actName = "";
              if (fileNo ==0)
              rowTitle = sheet.createRow((short)0);
              rowTitle.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)0).setCellValue("Req/Res");
              rowTitle.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)1).setCellValue("Action");
              rowTitle.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)2).setCellValue("Server Time(in ms)");
              rowTitle.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)3).setCellValue("Request Vs Response Time in Server(in ms)");
              rowTitle.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)4).setCellValue("Time Taken By HAS/HOST(in ms)");
              rowTitle.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)5).setCellValue("No. of HAS calls");
              rowTitle.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)6).setCellValue("Data Size");
              //wb.write(fileOut);
    while((aLine=logReader.readLine()) != null) {
    if(aLine.startsWith("<MESSAGE TYPE=\"EVENT\"")) {
    Matcher m = startMessage.matcher(aLine);
    if(m.find()) {
    sBuf.setLength(0);
    sBuf.append(aLine);
    skip = false;
    initReq = false;
    m = initMessage.matcher(aLine);
    if(m.find()) {
    initReq = true;
    } else {
    if(initReq) {
    m = initResMessage.matcher(aLine);
    if(m.find()) {
    sBuf.setLength(0);
    sBuf.append(aLine);
    skip = false;
    } else if(aLine.startsWith("</MESSAGE>")) {
    if(!skip) {
    sBuf.append(aLine);
    readed = true;
    } else if(!skip){
    sBuf.append(aLine);
    if(!skip && readed) {
    String tempStr = sBuf.toString();
    if(tempStr.length() > 0) {
    boolean reqMatched = false;
    Matcher m = null;
    if(initReq) {
    m = initMessage.matcher(tempStr);
    actName = "Intialization";
    } else {
    m = requestMessage.matcher(tempStr);
    String time = "";
    if(m.find()) {
    reqMatched = true;
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    if(i == 1) {
    time = groupStr;
    } else if(i == 2) {
    actName = groupStr;
    } else if(!initReq){
    m = requestMessage1.matcher(tempStr);
    if(m.find()) {
    reqMatched = true;
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    if(i == 1) {
    time = groupStr;
    } else if(i == 2) {
    actName = groupStr;
    if(time.length() > 0 ) {
    try{
    requestTime = sdf.parse(time).getTime();
    }catch(Exception ex){}
    System.out.println("Request,"+actName+","+time+",,,,"+dcf.format(((double)time.length()/1024.0))+"K");
                                  //bw.write("Request,"+actName+","+time+",,,,"+dcf.format(((double)time.length()/1024.0))+"K");
                                  String reqDataSize = dcf.format(((double)time.length()/1024.0))+"K" ;
                                  rowReq = sheet.createRow((short)counter);
                                       rowReq.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)0).setCellValue("Request");
                                       rowReq.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)1).setCellValue(actName);
                                       rowReq.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)2).setCellValue(time);
                                       rowReq.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)3).setCellValue("");
                                       rowReq.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)4).setCellValue("");
                                       rowReq.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)5).setCellValue("");
                                       rowReq.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)6).setCellValue(reqDataSize);
                                       counter = counter +1;
                                       System.out.println("counter is "+counter);
                             Matcher l = sentMessage.matcher(tempStr);
                             Matcher k = rcvdMessage.matcher(tempStr);
                   if(l.find()) {
                                            for (int i=1; i<=l.groupCount(); i++) {
         String groupStr2 = l.group(i);
    try{
    sentTime = sdf.parse(groupStr2).getTime();
    }catch(Exception ex){}
                        if(k.find())
                                                 for(int j=1;j<=k.groupCount(); j++) {
                                                 String groupStr1 = k.group(j);
                                                 try{
    recdTime = sdf.parse(groupStr1).getTime();
    }catch(Exception ex){}
                                                 presentTime = (recdTime - sentTime);
                                                 hasTime = hasTime + presentTime;
                                                 hasCalls = hasCalls +1;
    if(!reqMatched) {
    if(initReq) {
    m=initResIDMessage.matcher(tempStr);
    } else {
    m=responseMessage.matcher(tempStr);
    if(m.find()) {
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    try{
    responseTime = sdf.parse(groupStr).getTime();
    }catch(Exception ex){}
                                                 String resDataSize = dcf.format(((double)tempStr.length()/1024.0))+"K" ;
                                                 rowRes = sheet.createRow((short)(counter));
                                                 rowRes.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)0).setCellValue("Response");
                                                 rowRes.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)1).setCellValue(actName);
                                                 rowRes.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)2).setCellValue(groupStr);
                                                 rowRes.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)3).setCellValue((responseTime - requestTime));
                                                 rowRes.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)4).setCellValue(hasTime);
                                                 rowRes.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)5).setCellValue(hasCalls);
                                                 rowRes.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)6).setCellValue(resDataSize);
                                                 hasTime = 0;
                                                 hasCalls = 0;
                                                 counter = counter + 1 ;
    sBuf.setLength(0);
    readed = false;
              wb.write(fileOut);
              } // End of for (int fileNo = 0; fileNo < children.length; fileNo++ )
    }     //End of else
              fileOut.close();
    } //End of public static void main
    } // End of Class

    First of all, use [code]-tags to make your code readable, please.
    I didn't do a complete inspection of your code (because it's too much and unreadable as it is) and I don't know POI, but creating a new HSSFWorkbook for each input file sounds fishy to me ... try re-using the workbook and just creating a new sheet in each iteration.

  • Hibernate mapping XML files for the two SQL Server tables below.

    Hello all..,
    Question 1:
    I am working on a project that needs to support a database with an inherited legacy schema that you cannot change. The schema is provided below.Hibernate mapping XML files for the two SQL Server tables below. Please provide those two XML files. Assume some hypothetical package and class names. Assume that no "fancy" stuff such as lazy initialization, optimistic locking etc is needed at this time.
    CREATE TABLE [SURVEY_ANSWERS] (
    [ANSWER_ID] [int] IDENTITY (1,1) NOT NULL,
    [QUESTION_ID] [int] NOT NULL,
    [POSITION] [int] NULL,
    [TEXT] [varchar](350) NULL
    CREATE TABLE [dbo].[SURVEY_QUESTIONS] (
          [QUESTION_ID] [int] IDENTITY (1, 1) NOT NULL ,
          [TEXT] [varchar] (350) NULL
    GO
    ALTER TABLE SURVEY_ANSWERS
    ADD CONSTRAINT pk_SURVEY_ANSWERS PRIMARY KEY(ANSWER_ID,QUESTION_ID);
    ALTER TABLE [dbo].[SURVEY_QUESTIONS] ADD
           PRIMARY KEY  CLUSTERED
                [QUESTION_ID]
    GO
    ALTER TABLE [dbo].[SURVEY_ANSWERS] ADD
           FOREIGN KEY
                [QUESTION_ID]
          ) REFERENCES [dbo].[SURVEY_QUESTIONS] (
                [QUESTION_ID]
          )Question 2:
    Assume that you are working on a project developing, say, a banking application. You are the Architect and thinking that Hibernate ORM should be used for the entire access to the relational database. As usual, you have created (or auto-generated) a set of HBM XML files as well as POJOs for which you define the mappings. Assume now that a new requirement has just popped up. The system needs to be able to import new bank accounts and user information in bulk from a very large XML file at once and store it in the database. Assume the XML file contains all necessary information to populate fields in database tables. As performance is very important for this operation. Given this description, how would you approach the problem?
    Please describe briefly.
    -Thanks and regards
    Praveen Soni

    You're not fooling anyone Dennis_Mox. But nice try.Jeez, man. Mail me at denismox[at]yandex.ru, I will show you that exact test, dammit.

Maybe you are looking for