A JDBC Program to Access/Read Microsoft Excel : Excel « Database « Java Tutorial

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Main {

  public static Connection getConnection() throws Exception {
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String url = "jdbc:odbc:excelDB";
    String username = "yourName";
    String password = "yourPass";
    return DriverManager.getConnection(url, username, password);

  public static void main(String args[]) throws Exception {
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;

    conn = getConnection();
    stmt = conn.createStatement();
    String excelQuery = "select * from [Sheet1$]";
    rs = stmt.executeQuery(excelQuery);

    while (rs.next()) {
      System.out.println(rs.getString("FirstName") + " " + rs.getString("LastName"));

20.36.1.A JDBC Program to Access/Read Microsoft Excel
20.36.2.Write Data to a Microsoft Excel Spreadsheet File
20.36.3.Read data from Excel worksheet
20.36.4.Read data from Excel
20.36.5.Use JDBC ODBC bridge to read from Excel