I have failed with all possibilities that I know to make this program success. Need your help.
Getting error as
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Program goes like this.
import java.sql.*;
public class ExcelConnection {
public static void main (String[] args){
try{
Connection conn = getConnection("TEST.xls");
Statement stmt = conn.createStatement();
}
catch(Exception e){
System.out.println(e);
}
}
public static Connection getConnection(String excel) throws Exception {
String xls_path="C:";
xls_path=xls_path.replace("\\", "/");
String xls=xls_path+"/"+excel;
String url = "jdbcdbcriver={Microsoft Excel Driver (*.xls)};DBQ="+xls; //$NON-NLS-1$
return DriverManager.getConnection(url);
}
}