• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to access data in excel

 
viswanath chennuru
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I am trying to access data that is present in MS excel and for that i have written the following program.The excel sheet name is "abc".

mport java.sql.*;


public class Main {
public static void main(String[] args) throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Statement stmt = DriverManager.getConnection("jdbc: odbc:abc").createStatement();
ResultSet rs = stmt.executeQuery("select * from [Sheet1$]");
while (rs.next()) {
String lname = rs.getString(1);
String fname = rs.getString(2);
int id = rs.getInt(3);
System.out.println(fname + " " + lname + " id : " + id);
}
rs.close();
stmt.close();
}
}

but when i am running it i am getting the following exception

Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.gwtbook.client.Main.main(Main.java:9)

Can someone tell me what the problem is??
 
sahar sa
Ranch Hand
Posts: 102
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear,
Did you set up your ODBC data source? if not
follow this :
http://www.corda.com/docsource/doc7/Manuals/install_admin/setting_up_the_example_odbc_data_source.htm

Regards,
Sahar.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic