Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Unable to establish connection to excel using JDBC:ODBC connection less statement

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Unable to establish connection to excel using JDBC:ODBC connection less statement

    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);
    }

    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Unable to establish connection to excel using JDBC:ODBC connection less statement

    Thread moved.

    Please post your code correctly using code or highlight tags which are explained near the top of this link.

Similar Threads

  1. Replies: 0
    Last Post: December 19th, 2013, 07:36 AM
  2. The Network Adapter could not establish the connection
    By alk3 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 19th, 2013, 06:31 PM
  3. What classes do I need to establish an ssh connection?
    By slashdevslashnull in forum Java Networking
    Replies: 2
    Last Post: June 30th, 2011, 10:41 PM
  4. jdbc connection problem
    By sny in forum JDBC & Databases
    Replies: 11
    Last Post: January 6th, 2011, 04:39 AM
  5. Unable to create a new connection!
    By fh84 in forum JDBC & Databases
    Replies: 1
    Last Post: November 20th, 2009, 05:58 PM