File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Reading .xls(Excel file) with JDBC (error-SQL exception) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Reading .xls(Excel file) with JDBC (error-SQL exception)" Watch "Reading .xls(Excel file) with JDBC (error-SQL exception)" New topic
Author

Reading .xls(Excel file) with JDBC (error-SQL exception)

abin awale
Greenhorn

Joined: Dec 23, 2008
Posts: 7
Hi everyone,

I am working on accessing .xls(Excel file) from JDBC.

I am trying example from:from here

In that example:
c = DriverManager.getConnection( "jdbc: odbc:qa-list", "", "" );
In my case:
c = DriverManager.getConnection( "jdbc: odbc:TeamList", "", "" );

In that example:
String query = "select URL from [qas$] where Month='March' and Year=2000;";

In my case:
String query = "select Name from [TestWithJavaForExcelSheet$] where Proff='programmer';";

I am getting error:
java.sql.SQLException: [Microsoft][ODBC Excel Driver] 'TestWithJavaForExcelSheet$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.

-> i have tried with TestWithJavaForExcelSheet (without $ sign/with $ sign)
and also I have done the configuration as shown in the link


Can anyone suggest me where I am missing ? Or where is the error.

----------------------------------------------------------------------------------------------------------------------------------------------------

Here is my code:



--> I even tried with short name like: test$... i.e my filename test.xls, but still giving same error

Thanks in advance,
Abin
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
JDBC isn't the appropriate API to interact with a spreadsheet. JDBC is intented to interact with a database. Besides, the ODBC bridge driver is almost the worst JDBC driver on the world.

To interact with spreadsheets, better use the appropriate API's for that. Commonly used ones are Apache POI HSSF/XSSF and Andy Khan's JExcelAPI. Information, documentation, tutorials/guides and examples are available at their homepages. Good luck.
abin awale
Greenhorn

Joined: Dec 23, 2008
Posts: 7
Ya thats true, Apache POI and JExcelAPI might be the best one for .xls or .doc files.....I was just trying this for the first time, so came across that tutorial..

Thanks anyway for the suggestion,
Abin
kalaiselvi Bhalerao
Greenhorn

Joined: Aug 19, 2011
Posts: 9
Dear Abin,

I want to know if you have explored Java with Excel. if yes, pl give me some idea about the website or books you refered I need to develop a small project by connecting java and excel.
Also pl let me know which is the best way to connect with excel JDBC or Jexcel API.
Thanks in advance.

regards
kalai
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
>Also pl let me know which is the best way to connect with excel JDBC or Jexcel API.
Apache POI should be the powerest api for Excel.
HXTT Excel is a commerical Excel JDBC solution.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading .xls(Excel file) with JDBC (error-SQL exception)
 
Similar Threads
Numeric field overflow while reading excel sheet values in jdbc
How to read and write data with excel?
Reading excel file with data in chinese language using jdbc
data source name too long
Reading XLS file