This code snippet converts the Excel file into a virtual database with the sheets as tables. No need to create and DSN in the system is the plus of this snippet.
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
Connection connection = DriverManager.getConnection(
"jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=F:\\Kishore\\exam.xls;
DriverID=22;READONLY=false","", "");
You can use the following query to get the values from the sheets.
select * from [Sheet1$]
The first row is considered as the column as usual. Here the empty columns will not be considered.
But there is a disadvantage in this. If you encounter let me know, i will give the solution :)
This entry was posted
on Jul 23, 2008
at Wednesday, July 23, 2008
and is filed under
Excel,
JDBC
. You can follow any responses to this entry through the
comments feed
.