Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>addthe excel file in ODBC Sources (from control panel->Administrative Tools) and then execute the code:</p> <pre><code>// program to extract data from excel file import java.sql.Connection ; import java.sql.Statement ; import java.sql.ResultSet ; import java.sql.ResultSetMetaData ; import java.sql.DriverManager ; import java.sql.SQLException ; public class ExtractExcelData { public static void main (String[] args) { try { Class.forName(DRIVER); connection = DriverManager.getConnection(URL,userName,password); } catch (ClassNotFoundException cnfe) { System.err.println("unable to load excel driver"); return ; } catch (SQLException se) { System.err.println("cannot connect to excel file"); return ; } try { statement = connection.createStatement(); String select = "SELECT * FROM [Sheet1$]"; resultSet = statement.executeQuery(select); metaData = resultSet.getMetaData(); int count = metaData.getColumnCount(); while ( resultSet.next() ) { String col1 = resultSet.getString(1) ; String col2 = resultSet.getString(2) ; String col3 = resultSet.getString(3) ; System.out.println( col1 ) ; System.out.println( col2 ) ; System.out.println( col3 ) ; System.out.println(); } } catch (SQLException se) { System.err.println("cannot execute query"); return ; } try { statement.close(); resultSet.close(); } catch (SQLException se ) { System.err.println("unable to close excel file"); return ; } } private static final String userName = "" ; private static final String password = "" ; private static final String URL = "jdbc:odbc:testexcel" ; private static final String DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver" ; private static Connection connection ; private static Statement statement ; private static ResultSet resultSet ; private static ResultSetMetaData metaData ; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload