Reading from Excel file, plz some help

A

ahmed.JDev

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 );
}
}
}
 
R

RedGrittyBrick

ahmed.JDev said:
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.
 
A

ahmed.JDev

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

ahmed.JDev said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top