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 3 of 3

Thread: Loading *.mdb database from local resources

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Loading *.mdb database from local resources

    Is it possible to load *.mdb database from a resource within a jar file?

    Here is sample code but I end up with an error.
    URL databaseResource = getClass().getResource("/resources/database.mdb");
    String databasePath = databaseResource.toString();
     
    String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+databasePath+";";
    Connection connection = DriverManager.getConnection(database, "", "");
     
    connection.close();

    The error message that I get is this...

    C:/Users/Development/Desktop/dist/Subscribers.jar!/resources/database.mdb
    [Microsoft][ODBC Microsoft Access Driver] Not a valid file name.

    Are there any ways around this?


  2. #2
    Member
    Join Date
    Nov 2013
    Location
    Bangalore, India
    Posts
    70
    My Mood
    Cool
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: Loading *.mdb database from local resources

    There are plugins available to read jarfile and using that you can get the URL for the DB and then instantiate to use it.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,775
    Thanks
    54
    Thanked 2,340 Times in 2,311 Posts

    Default Re: Loading *.mdb database from local resources

    Not a valid file name.
    Can the DB driver read from a stream vs from a file?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Loading Resources: Maven Project Structure vs Jar
    By aussiemcgr in forum Java IDEs
    Replies: 13
    Last Post: August 12th, 2014, 07:40 AM
  2. Loading Resources: Maven Project Structure vs Jar
    By aussiemcgr in forum What's Wrong With My Code?
    Replies: 9
    Last Post: March 1st, 2013, 10:13 PM
  3. Connecting to local access database
    By Moses76 in forum JDBC & Databases
    Replies: 1
    Last Post: February 29th, 2012, 02:39 PM
  4. Can single MDB subscribe multiple topics?
    By shptlucky in forum Web Frameworks
    Replies: 0
    Last Post: April 22nd, 2011, 06:52 AM
  5. error in deploying MDB
    By s.saikia in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: October 4th, 2009, 01:06 PM

Tags for this Thread