JSP Connection to Microsoft Access Database

  OK Computer 16:25 16 Feb 2005

I'm trying to connect a jsp page (or what is actually a java bean) to connect to a simple microsoft access database WITHOUT using DSN.

I have the following code:

Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=GuestBook.mdb;");
java.sql.Statement statement = conn.createStatement();

But when I try to add something to the database I get the following error message

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Any ideas? I have tried using the full path to the database (i.e. c:\tomcat etc etc) but get nowhere! HELP!

  Taran 17:33 16 Feb 2005

Before we go into this and I start getting a headache (I detest JSP but enjoy telling people that fact) have you tried setting up a system DSN and attempting a working connection ?

I only suggest this as a first stage step becasue by doing so it will verify that other aspects of a possible connection problem are not the cause and will help narrow the problem down for me. There are lots of things that could be going on and it would help to see the whole page code and not just a connection snippet, but the system DSN method will at least verify certain theings.

Try configuring a system DSN, the try to get a working connection going. Post with your results and we'll go from there.

  OK Computer 12:57 17 Feb 2005

OK, so I setup a DSN connection and connected to the database without a problem.

However, as ever, another problem has come up. It cannot post data to the database. I can read what is in there and add manually by going into the database but cannot post information into it.

The basic connection seems to work fine though.

  OK Computer 13:23 17 Feb 2005

When I say I connect without a problem, I have just discovered that even though I have the contents of my database returned and is viewable my tomcat command prompt is appending the exact same error message that I used to receive with the DSN-less connection.

Confused! And beginning to get that headache you mentioned!

  Taran 16:53 17 Feb 2005

Before we get into silly territory, try sharing the directory your web/database is in.

I'm not a fan of enabling simple file sharing but often on a Windows machine it sharing a folder (and thereby its contents) renders the database inside it fully operational.

I know it sounds strange, but believe me its true, although not necessarily in this case.

After that point we can start getting into correct paths, perhaps download a connection driver and whatnot, but let's rule out the more obvious things for now.

  Taran 17:40 17 Feb 2005

Establishing a connection and actually being able to write to the database are two different things.

More often than not simply sharing the database directory will resolve such issues.

This is not necessarily the place for a lengthy discussion on file/folder permissions and it would largely depend on which operating system you are using and file format your hard disk is running (FAT32 or NTFS).

Most of my students find that sharing their directory renders the database writeable, but you should be aware of potential security issues in doing so.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

AMD Radeon Adrenalin release date, new features, compatible graphics cards

Artist Pete Oswald on creating relatable characters & his new book

New iMac Pro release date, UK price & specs rumours

Idées cadeaux pour geeks et tech addicts