hi guys... Can anyone guide to how to connect to an excel file through JDBC-ODBC bridge. I want to know what is written in the sql query instead of the tables is this query right "SELECT fruits from SHEET$1" where fruit is a column is sheet1 I know there are are a lot of post on this question in javaranch can any one send the urls to those discussions.... thanks a lot Farooq
Mark Simms
Ranch Hand
Joined: Jul 20, 2000
Posts: 36
posted
0
1) create a DSN that points to the excel (xls) file 2) apply this coding pattern usnig Sam$ as the sheet name: import java.sql.*; class JavaExcel { JavaExcel() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc dbc:JavaExcel","",""); Statement st = con.createStatement(); ResultSet rs = st.executeQuery("Select Name,Marks from [Sam$]"); while (rs.next()) { System.out.println(rs.getString("Name")); System.out.println(rs.getInt("Marks")); System.out.println("-------"); } } catch (Exception e) {e.printStackTrace();} } public static void main(String[] args) { new JavaExcel(); } }
Mark
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.