Reading from Excel file, plz some help

Discussion in 'Java' started by ahmed.JDev, Oct 6, 2008.

  1. ahmed.JDev

    ahmed.JDev Guest

    Hello all,
    i tried to read some data from Excel file via this code, but i got an
    exception
    ( 'an$' is not a valid name..... )
    hint: i made the settings in Control Panel>Administrative tools>Data
    Sources(ODBC)

    public class ExcelReader
    {
    public static void main( String[] args )
    {
    Connection c = null;
    Statement stmnt = null;

    try {
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection( "jdbc:eek:dbc:an-list", "", "" );
    stmnt = c.createStatement( );

    String query = "select URL from [an$] where Name='Ahmed Battah' and
    Ext=213";
    ResultSet rs = stmnt.executeQuery( query );

    System.out.println( rs.getString( "URL" ) );
    }
    catch( Exception e ) {
    System.err.println( e );
    }
    }
    }
     
    ahmed.JDev, Oct 6, 2008
    #1
    1. Advertising

  2. ahmed.JDev wrote:
    > Hello all,
    > i tried to read some data from Excel file via this code, but i got an
    > exception
    > ( 'an$' is not a valid name..... )
    > hint: i made the settings in Control Panel>Administrative tools>Data
    > Sources(ODBC)
    >

    [snip]
    > String query = "select URL from [an$] where Name='Ahmed Battah' and Ext=213";


    Your Excel file doesn't contain a worksheet named "an"?

    I must admit that to read Excel files, I'd not think of JDBC ODBC.
    http://poi.apache.org/

    P.S. I think you omitted a call to rs.next(); THis sin't the cause of
    your reported exception but I expect it will be your next problem.

    --
    RGB
     
    RedGrittyBrick, Oct 6, 2008
    #2
    1. Advertising

  3. ahmed.JDev

    ahmed.JDev Guest

    you right, the problem was in sheet name.
    and about rs.next( ) i wrote it.
    its work now..
    thank you friend,


    RedGrittyBrick wrote:
    > ahmed.JDev wrote:
    > > Hello all,
    > > i tried to read some data from Excel file via this code, but i got an
    > > exception
    > > ( 'an$' is not a valid name..... )
    > > hint: i made the settings in Control Panel>Administrative tools>Data
    > > Sources(ODBC)
    > >

    > [snip]
    > > String query = "select URL from [an$] where Name='Ahmed Battah' and Ext=213";

    >
    > Your Excel file doesn't contain a worksheet named "an"?
    >
    > I must admit that to read Excel files, I'd not think of JDBC ODBC.
    > http://poi.apache.org/
    >
    > P.S. I think you omitted a call to rs.next(); THis sin't the cause of
    > your reported exception but I expect it will be your next problem.
    >
    > --
    > RGB
     
    ahmed.JDev, Oct 7, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bluewind44
    Replies:
    4
    Views:
    3,528
    =?Utf-8?B?UHJhZGVlcCBT?=
    May 1, 2006
  2. Replies:
    1
    Views:
    414
  3. Replies:
    2
    Views:
    365
    Nick Keighley
    Nov 24, 2006
  4. Replies:
    1
    Views:
    379
  5. nocturnal
    Replies:
    1
    Views:
    559
    nocturnal
    Jul 10, 2009
Loading...

Share This Page