jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes how to access data in excel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "how to access data in excel" Watch "how to access data in excel" New topic

how to access data in excel

viswanath chennuru

Joined: Aug 19, 2009
Posts: 3
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 {
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);

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

Joined: Jul 06, 2009
Posts: 102
Did you set up your ODBC data source? if not
follow this :

I agree. Here's the link: http://aspose.com/file-tools
subject: how to access data in excel
jQuery in Action, 3rd edition