0

i want to run sql queries on Microsoft excel, so that i can fetch any row or any column based on the sql query. Below is the code which i have written

Connection con = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:Driver={Microsoft Excel Driver(*.xls)};DBQ="+path+"; ReadOnly=0");`

// Here path is the path to the excel file in my local.

When i run this i am getting invalid oracle URL specified error. I have a doubt on the URL format that i need to specify for querying excel sheets. Is there any other way to read excel sheet using sql queries without using DSN.

java.sql.SQLException: Invalid Oracle URL specified
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:191)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:287)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:550)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
DanielBarbarian
  • 5,093
  • 12
  • 35
  • 44
user3654024
  • 13
  • 2
  • 5

1 Answers1

2

See Connecting to excel sheet using jdbc without specifying DSN to Excel sheet

You certainly don't want to use the Oracle driver for this.

Community
  • 1
  • 1
Piotr Wilkin
  • 3,446
  • 10
  • 18