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)
5
  • 4
    Why are you trying to use an Oracle driver to access Excel? Commented Aug 17, 2016 at 11:10
  • What is the path you're supplying? Commented Aug 17, 2016 at 11:10
  • path is the location of the xls file. Ex: C:\\test.xls Commented Aug 17, 2016 at 11:40
  • As per my knowledge JDBC driver is not supported by Java8. Hence i am using oracle driver. By using this simply i can query the excel and get the specific cell value. Commented Aug 17, 2016 at 11:41
  • The Oracle driver can only connect to the Oracle database. Why do you even think this would work? Commented Aug 18, 2016 at 10:12

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.