We're starting to experiment with JDBC, and as a first test, I'm just trying to read from a Microsoft Access database. When I access the database via a normal command-line Java program, I can access it without any problems. However, when I use the exact same connection code via a servlet, I get an error.
Here is the BeerExpert class, which accesses the database:
Here's the BeerExpertTester class, which calls the BeerExpert class. It works fine from the command-line:
Here's the BeerExpertServlet class, which calls the BeerExpert class. When it does so, it gets a SQLException error:
I hadn't set up an ODBC Data Source before, so it's possible that I've somehow messed that up. However, since it works for the standalone command-line version, that seems unlikely. Just in case, though, here are the steps I took. To set up the Beer ODBC DSN, I:
Brought up the ODBC Data Source Administrator
Selected the "System DSN" tab
Selected "Microsoft Access Driver (*.mdb)"
Entered "Beer" as the Data Source Name
Browsed to the database, selected it, and clicked "OK"
The error that I'm getting is "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.", with an ErrorCode of "-1023" and a SQLState of "S1009".
All of this is on Windows XP Pro. Any suggestions?
Joined: Jan 30, 2003
I've figured out a partial solution to the problem. For some reason, when the *.mdb file is located on the C: drive, we can access it fine. However, when it is located on the G: drive (which is actually just a mapped network drive located on a Novell Netware server), then it doesn't work for the servlet (although it works for the command-line version in both cases). Odd.
Any ideas as to why that would be the case? (Yes, I have write access to the file on the network drive.)