Results 1 to 7 of 7
  1. #1
    DerekRaimann is offline Member
    Join Date
    Dec 2010
    Posts
    45
    Rep Power
    0

    Default 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

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    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.

  3. #3
    DerekRaimann is offline Member
    Join Date
    Dec 2010
    Posts
    45
    Rep Power
    0

    Default

    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

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    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.

  5. #5
    DerekRaimann is offline Member
    Join Date
    Dec 2010
    Posts
    45
    Rep Power
    0

    Default

    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

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    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.

  7. #7
    DerekRaimann is offline Member
    Join Date
    Dec 2010
    Posts
    45
    Rep Power
    0

    Default

    Lol, I'll get better as time goes by I hope! Thanks again for all of your help Tolls! :)

    -Derek Raimann

Similar Threads

  1. java.sql.SQLException: Closed Connection
    By sunjavaboy in forum JDBC
    Replies: 4
    Last Post: 03-21-2012, 01:38 PM
  2. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  3. connect to derby thrown SQLException
    By newbiejava in forum New To Java
    Replies: 5
    Last Post: 01-20-2010, 05:25 PM
  4. SQLException: Communications link failure
    By etherkye in forum JDBC
    Replies: 0
    Last Post: 07-03-2009, 04:20 PM
  5. Replies: 3
    Last Post: 03-08-2009, 01:51 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •