0

Excel has a built-in option to use a file as a database (view), but how we'd go about connecting and using this is an absolute mystery.

This is the returned connection string:

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;
Initial Catalog=Foo_appviews;Data Source=foo.domain.com;
Use  Procedure for Prepare=1;Auto Translate=False;Packet Size=2048;
Workstation ID=UID001;Use Encryption for Data=False;
Tag with column collation when possible=False

How would we go about using this in our DriverManager.getConnection()?

try
    {
        Connection conn=DriverManager.getConnection("Provider=SQLOLEDB.1;Integrated security=SSPI;Persist Security Info=True;
        Initial Catalog=Foo_appviews;Data Source=foo.domain.com;
        Packet Size=2048;
        Workstation ID=UID001");

        Statement stment = conn.createStatement();
        String qry = "SELECT foo FROM db";

        ResultSet rs = stment.executeQuery(qry);
        while(rs.next())
        {
            System.out.println(rs.toString());
        }
    }
    catch(Exception err)
    {
        System.out.println(err);
    }

Any help would be appreciated

3
  • Do you ever search? Using excel sheet as a database with java Commented Dec 22, 2016 at 8:05
  • Yes, I did search. Seeing as my code is near identical to that link. "java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver" Commented Dec 22, 2016 at 8:13
  • it seems you don't have the required driver, make sure you have the corresponding jar in your classpath. Commented Dec 22, 2016 at 8:21

0

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.