Sono riuscito a connettermi al file adesso però non so la sintassi esatta che usa excel per fare le query.
Questo è il codice ora sto cercando come si scrivono le query (quella che posto ha il codice non corretto)
codice:private Vector getCity() { Vector city = null; String yourDB = "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=C:\\eclipse\\workspace\\Prova3\\tbcomuni.xls"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { Connection c = DriverManager.getConnection(yourDB, "", ""); Statement s = c.createStatement(); // SQL code: ResultSet r = s.executeQuery("Select * from [tbcomuni$].B") where [tbcomuni$].A = 'FIRENZE'"); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } return city; }

Rispondi quotando