0
import sun.jdbc.odbc.*;
import java.sql.*;

class excelWorkBook
{
    public static void main(String args[]) throws SQLException
    {
        JdbcOdbcDriver d = new JdbcOdbcDriver();
        DriverManager.registerDriver(d);
        Connection con = DriverManager.getConnection("jdbc:odbc:xdsn");


        Statement st = con.createStatement();
        String query = "SELECT * FROM [beers$]";
        ResultSet rs = st.executeQuery(query);


        while(rs.next())
        {

            System.out.println(rs.getInt(1)+" "+rs.getInt(2)+"    "+rs.getInt(3)+" "+rs.getInt(4)+" "+rs.getInt(5));
        }
        st.close();
        con.close();

    }
}

java.sql.Exception: [Microsoft][ODBC excel driver] beers$ is not a valid name.

I'm getting above exception while running the program

Varun
  • 35
  • 1
  • 6
  • I'd add some more background information: OS, app versions, and where is that "beers" table you're trying to refer to. – einpoklum Mar 27 '16 at 09:54
  • http://stackoverflow.com/a/18181290/5611377, does this answer fit? I think you have to refer to the file containing your sheet before executing a query on it. – ssimm Mar 27 '16 at 10:10

0 Answers0