I'm sure I'm being a royal pain in the butt with all of my questions but this project I'm working on is driving me nuts and I've found that this is the best place to come to when I need some help.
So, I've written this code to connect to an access database on my hard drive. I found the code to do this here using the direct connect method. Everything appeared to connect correctly until I added the statement. Now I'm getting the following error when it catches:
It provides no specifics and I'm sure its the statement I'm just not sure what could be wrong with it. Any ideas? Code is below...
That's your error message that gives no specifics, actually. When an exception is thrown, it's a good idea to print the stack trace. This tells you what class of exception was thrown, and what line of code threw it. Like this:But for now I'm going to guess that the exception occurs when you try to execute the SQL insert statement:Perhaps the employees table doesn't have exactly three columns. Or perhaps not all of them contain string data. Or perhaps the first one only allows strings of three characters or fewer. At any rate something's wrong with it, and you would have to check your table definition to find out just what. That's assuming that my guess was right about what line of code is throwing the exception.
Joined: Sep 19, 2003
I double checked my database - all three fields are text. The first is limited to 5 chars, the other two to 50, so my configuration doesn't appear to be the problem as far as I can tell. I did as you said and changed the error to a stack trace, this is the error it shows now:
It is indeed that line but I'm not sure what these errors mean, not to familiar with this stuff.
These two lines of the stack trace:tell you that the exception occurred at line 14 of your TestDB class, in the "main" method, where you were calling the "execute" method. So, it tells you exactly what line threw the exception.
As for why it threw the exception, it's a crummy Access error message. Something's wrong with your query, and that's all it's telling you. Maybe making that insert would result in duplicate keys or something like that. You're going to have to look at your database setup more closely.
Joined: Sep 19, 2003
This isn't an issue with this specific table because it doesn't use it - but how does JDBC deal with a field in an access database with an auto increment set on it?