Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Reading from Excel file, plz some help

Reply
Thread Tools

Reading from Excel file, plz some help

 
 
ahmed.JDev
Guest
Posts: n/a
 
      10-06-2008
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( "jdbcdbc: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 );
}
}
}

 
Reply With Quote
 
 
 
 
RedGrittyBrick
Guest
Posts: n/a
 
      10-06-2008

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
 
Reply With Quote
 
 
 
 
ahmed.JDev
Guest
Posts: n/a
 
      10-07-2008
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
plz help me ,, i need some codes ,,plz enter nocturnal VHDL 1 07-10-2009 07:43 AM
req:can some 1 plz get just my luck in here plz thankx u this is my1st post Rollson Computer Support 1 06-19-2006 08:47 PM
Some data is missing when Excel Import. (T.T plz help.) bluewind44 ASP .Net 4 05-01-2006 04:36 PM
Re: plz help!!! plz plz plz plzplzplz help the noob alkzy Microsoft Certification 0 10-31-2004 10:04 PM
Computer Problems... Plz Plz Plz HELP ME..... Nick Computer Support 0 06-04-2004 08:50 PM



Advertisments