DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: [Microsoft][ODBC Microsoft Driver]

  1. #1
    Guest

    [Microsoft][ODBC Microsoft Driver]

    For starters I'm new to Java.

    I am using a JFileChooser to select a Access database to open. I'm using a
    DSN less connection and I can't seem to figure out what I'm doing wrong I
    keep getting this error message. [Microsoft][ODBC Microsoft Driver]
    '(unknown)' is not a valid path. Make sure that the path is spelled
    correctly and that you are connected the server on which the file resides
    SQL state:S1009 Vender code: -1023.

    This is my Connection string.

    String url = "jdbcdbcriver={Microsoft Access Driver (*.mdb)};DBQ=" +
    returnedFile.getPath() + "\\" + returnedFile.getName();

    Connection cnConnection = DriverManager.getConnection(url );

    The variable returnedFile is file object returned from the JFileChooser's
    getSelectedFile() method.
    I was thinking that returnedFile.getPath() string has a single \ and that
    I might have to find every \ and replace it with "\\".
    Some examples of the connection string the path where the .mdb file is
    looks like "C:/folder1/folder2/somedb.mdb"
    why on a windows os would the path have forward slashes??


    Any help or advise would be greatly appreciated.
    Thanks



  2. #2
    Carlos Saltos Guest

    Re: [Microsoft][ODBC Microsoft Driver]


    Hi Even:

    Java is an interesting language and now is a powerful development platform.
    At the beging you will face strange thinks like the slashes issue. Many operating
    systems like linux, solaris, aix and other use foreward slashes (/) for the
    paths, and also other schemes like in URL addresses, CVS repositories and
    others ... in fact I don't know why windoze choose the other way around,
    but it is not a big deal ... you just replace the backslashes (\) for the
    foreward slashes (/) on windoze.

    About your error, may be the driver is confused if you mix the back slashes
    and the foreward slashes in the same path, so please try to provide a path
    using just foreward slashes ... and if that does not work, try to use only
    backslashes ... also try to print the URL connection to check if the path
    is correct.

    Also as a general recomendation is better if you try to lean JDBC using MySQL
    in windoze ... is less error prone and can safe you some headaches ... also
    you will be able to move to oracle, sybase, postgres, db2 and other real
    databases begining with MySQL. Access has serious limitations.

    And maybe you can use linux instead of windoze, but maybe that is to much
    for you, you can learn better java on linux, and also you can move to solaris,
    aix, and other real operating systems if you use linux.

    I'm glad you are learning java, please keep going, some aspects of the language
    are kind of wired but with the time you will learn how to manage it and then
    enjoy developing great solutions.

    Please let me know if you still have problems with the JDBC connection. And
    don't give up ! ... the database connections are always frustrating but once
    you get them the fun is about to begin !

    Best regards,

    Carlos Saltos
    Infoobar
    IT Manager
    http://www.infoobar.com/

    <Even> wrote:
    >For starters I'm new to Java.
    >
    >I am using a JFileChooser to select a Access database to open. I'm using

    a
    >DSN less connection and I can't seem to figure out what I'm doing wrong

    I
    >keep getting this error message. [Microsoft][ODBC Microsoft Driver]
    >'(unknown)' is not a valid path. Make sure that the path is spelled
    >correctly and that you are connected the server on which the file resides
    >SQL state:S1009 Vender code: -1023.
    >
    >This is my Connection string.
    >
    > String url = "jdbcdbcriver={Microsoft Access Driver (*.mdb)};DBQ="

    +
    >returnedFile.getPath() + "\\" + returnedFile.getName();
    >
    > Connection cnConnection = DriverManager.getConnection(url );
    >
    >The variable returnedFile is file object returned from the JFileChooser's
    >getSelectedFile() method.
    >I was thinking that returnedFile.getPath() string has a single \ and that
    >I might have to find every \ and replace it with "\\".
    >Some examples of the connection string the path where the .mdb file is
    >looks like "C:/folder1/folder2/somedb.mdb"
    >why on a windows os would the path have forward slashes??
    >
    >
    >Any help or advise would be greatly appreciated.
    >Thanks
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center