Results 1 to 7 of 7
Thread: SQLException errors - need help!
- 01-27-2011, 07:42 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 45
- Rep Power
- 0
SQLException errors - need help!
I have a program that I am trying to run that takes in text from an online .csv file and attempts to place that result into an Access database file. When the statement is executed to insert the values I get an error:
SQL Error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
SQL State: 22005
SQL Error Code: -3030
How can I go about getting more detailed information? Also, is there a way to have the error include the line that it is encountering the problem on? That would help for future applications at least. If anyone should need me to post the code, I will post it, it is close to 100 lines long, so I'll only throw it up here if necessary. Thank you so much for your help and for taking the time to read this!
-Derek Raimann
- 01-27-2011, 08:37 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
What does the code look like and the data that you are trying to insert?
Essentially it looks like you are trying to do something in your SQL where two datatypes don't match and Access can't make a guess at a conversion. Without the code, though, I can't say more than that.
We only need to code around building the query...but you could help by initially sticking more debugging code in. For starters on an exception you should have a stack trace.
- 01-27-2011, 08:56 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 45
- Rep Power
- 0
I just learned after a couple of hours of playing around that, at least in Access database format, the field name of 'open' is unacceptable. When I stop trying to insert a value into this field, the script runs fine. I downloaded a program that allows you to create Access database files from scratch and upon trying to create a field called 'open', the program would produce error messages. So I changed the name of the field to 'openValue' instead, rewrote the script to reflect the changes and it works.
Tolls, could you tell me how to produce a stack trace when catching an SQLException? I tried this, sqe is the name of the SQLException object btw:
System.out.println("Stack Trace: " + sqe.printStackTrace());
This line didn't work, apparently SQLException exceptions aren't given a printStackTrace() method from what I saw on the Oracle site. Is there another way? Thanks a million!
-Derek Raimann
- 01-27-2011, 09:16 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Just do sqe.printStackTrace().
That'll send the stack trace to out.
The error you got was probably simply saying that printStackTrace() has no return parameter, so you can't append it to a String.
- 01-27-2011, 09:21 AM #5
Member
- Join Date
- Dec 2010
- Posts
- 45
- Rep Power
- 0
Nice, that worked, now I'm getting the stack trace. I forced the query to crash by putting in an field name that didn't exist and it looked like that error is at least more specific. Do you know of anyway to find out what field is the problematic one in the case of the error I mentioned previously with Data type mismatch? Thanks again!
-Derek Raimann
- 01-27-2011, 09:34 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Welcome to SQL errors.
You rarely get enough info to figure out exactly what's wrong...even on posh dbs like Oracle and SQL Server.
:)
However, it's usually possible to spot the problem fairly easily once you;ve had some practice.
- 01-27-2011, 10:00 AM #7
Member
- Join Date
- Dec 2010
- Posts
- 45
- Rep Power
- 0
Similar Threads
-
java.sql.SQLException: Closed Connection
By sunjavaboy in forum JDBCReplies: 4Last Post: 03-21-2012, 01:38 PM -
First Java Program-Compile Errors (errors are posted)-simple GUI
By cc11rocks in forum AWT / SwingReplies: 4Last Post: 01-04-2011, 12:36 AM -
connect to derby thrown SQLException
By newbiejava in forum New To JavaReplies: 5Last Post: 01-20-2010, 05:25 PM -
SQLException: Communications link failure
By etherkye in forum JDBCReplies: 0Last Post: 07-03-2009, 04:20 PM -
What is the difference between Semantic Errors and Logical Errors?
By tlau3128 in forum New To JavaReplies: 3Last Post: 03-08-2009, 01:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks