Results 1 to 6 of 6
  1. #1
    siddu is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default How to get data from 2nd row in Excel using JDBC

    Hi,
    Here, am stucking at this point. I have an excel sheet. From this excel i need to get the data and i dont want first 2 rows data. The column names are in 3rd row and I need to select the excel at run time, but not at the time of DSN creation.
    Please help on this

  2. #2
    foulkelore is offline Member
    Join Date
    Dec 2012
    Location
    Des Moines, IA
    Posts
    33
    Rep Power
    0

    Default Re: How to get data from 2nd row in Excel using JDBC

    How about you show us the work you have done so far. Have you looked into Apache POI?

  3. #3
    siddu is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default Re: How to get data from 2nd row in Excel using JDBC

    Thanks for your reply.
    No, I didnt check with POI.

  4. #4
    siddu is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default Re: How to get data from 2nd row in Excel using JDBC

    And am trying to create DSN at run time. I have tried with the below code. Please have a look.

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    PrintWriter pw=response.getWriter();

    //establish connection
    String url = "jdbc:odbc:Driver={MicroSoft Excel Driver (*.xls,*.xlsx)};DBQ=D:\\Jagadeesh\\Sample.xls";
    con=DriverManager.getConnection(url,"","");

    //create a statement
    stmt=con.createStatement();

    //execute the statement
    ResultSet rs=stmt.executeQuery("select distinct id,sal,name from [Sheet1$]");
    while(rs.next())
    {
    String did=rs.getString(1);
    String name=rs.getString(2);
    String date=rs.getString(3);
    pw.println(did+" "+name+" "+date);
    }

  5. #5
    siddu is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default Re: How to get data from 2nd row in Excel using JDBC

    And here i attached my Sample.xls file

    How to get data from 2nd row in  Excel using JDBC-aa.jpg

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is online now Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    10,101
    Rep Power
    17

    Default Re: How to get data from 2nd row in Excel using JDBC

    Why do they call it rush hour when nothing moves? - Robin Williams

Similar Threads

  1. getting data from excel
    By laosu in forum New To Java
    Replies: 2
    Last Post: 02-17-2011, 08:29 AM
  2. How to add data into excel file
    By computechsolutions in forum JDBC
    Replies: 1
    Last Post: 10-04-2010, 12:29 PM
  3. How to fetch integer data from excel
    By nehakuls in forum JDBC
    Replies: 5
    Last Post: 11-24-2009, 01:52 PM
  4. Excel Multibyte JDBC Driver / Very Urgent Requirement
    By phanindar in forum Advanced Java
    Replies: 0
    Last Post: 11-17-2008, 11:46 AM
  5. Reading data form Excel using Jdbc (example)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-13-2008, 11:23 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •