SQLException: General Error

Discussion in 'Java' started by HightowerC, Sep 22, 2008.

  1. HightowerC

    HightowerC Guest

    Hello all.

    I have a problem, and it has got me stumped.

    I've got a PreparedStatment defined as follows:
    insertStmt = conn.prepareStatement(
    "insert into document_filing ( " +
    " case_id, " +
    " event_id, " +
    " path, " +
    " pages," +
    " last_updated_by, " +
    " last_updated_datetime, " +
    " last_updated_from) " +
    "values (?, ?, ?, ?, ?, ?, ?)");

    I then call the PreparedStatment.setXXX methods to set the values for
    the various fields.
    I have checked these against my database, and I am setting the fields
    to the proper type (i.e.
    I'm using setInt on an Integer field, and setString on a VARCHAR
    field).

    I run the insert query by the following statment:

    rowsInserted = insertStmt.executeUpdate();

    At this point, I sometimes (randomly it seems) get a
    java.sql.SQLException: General Error
    This "General Error" doesn't tell me much. I've googled, and the
    responses usually say something like
    "You're closing the connection or the preparedStatment before the
    update." I can assure you that this is
    not the case. The connection is open, the preparedStatment is created
    properly, the values are set to the
    proper type, none of the values are NULL, the data looks (almost)
    exactly like data that gets passed through
    this query and doesn't throw an exception.

    Does anyone have any idea what might be causing this "General Error"?
    My team and I are stuck.
    HightowerC, Sep 22, 2008
    #1
    1. Advertising

  2. On Mon, 22 Sep 2008 11:25:40 -0700, HightowerC wrote:

    > Hello all.
    >
    > I have a problem, and it has got me stumped.
    >
    > I've got a PreparedStatment defined as follows: insertStmt =
    > conn.prepareStatement(
    > "insert into document_filing ( " +
    > " case_id, " +
    > " event_id, " +
    > " path, " +
    > " pages," +
    > " last_updated_by, " +
    > " last_updated_datetime, " + "
    > last_updated_from) " +
    > "values (?, ?, ?, ?, ?, ?, ?)");
    >
    > I then call the PreparedStatment.setXXX methods to set the values for
    > the various fields.
    > I have checked these against my database, and I am setting the fields to
    > the proper type (i.e.
    > I'm using setInt on an Integer field, and setString on a VARCHAR field).
    >
    > I run the insert query by the following statment:
    >
    > rowsInserted = insertStmt.executeUpdate();
    >
    > At this point, I sometimes (randomly it seems) get a
    > java.sql.SQLException: General Error
    > This "General Error" doesn't tell me much. I've googled, and the
    > responses usually say something like
    > "You're closing the connection or the preparedStatment before the
    > update." I can assure you that this is not the case. The connection is
    > open, the preparedStatment is created properly, the values are set to
    > the
    > proper type, none of the values are NULL, the data looks (almost)
    > exactly like data that gets passed through this query and doesn't throw
    > an exception.
    >
    > Does anyone have any idea what might be causing this "General Error"? My
    > team and I are stuck.


    That all looks OK. Obvious questions:

    - What RDBMS are you using?

    - Is the connection always prepared to accept updates?

    - How are you handling commits?

    Silly question: I suppose you've loaded the code with trace statements
    sufficiently to know that it is the executeUpdate() that's throwing the
    exception, not anything else?


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
    Martin Gregorie, Sep 22, 2008
    #2
    1. Advertising

  3. HightowerC

    HightowerC Guest

    On Sep 22, 4:18 pm, Martin Gregorie
    <> wrote:
    >
    > That all looks OK. Obvious questions:
    >
    > - What RDBMS are you using?
    >
    > - Is the connection always prepared to accept updates?
    >
    > - How are you handling commits?
    >
    > Silly question: I suppose you've loaded the code with trace statements
    > sufficiently to know that it is the executeUpdate() that's throwing the
    > exception, not anything else?


    RDMBS is MySQL 5.0 (and MS Access. I know, I know, it wasn't my idea.)
    It fails in both.

    I get the connection from another method in a superclass
    (getConnection(connectionString)). I assume it is prepared to accept
    updates, because it works most of the time.

    commits are handled in the finally block like this:

    finally {
    try {
    if (insertStmt != null) {
    insertStmt.close();
    }
    } catch (SQLException sqle) {
    //this isn't the place I'm getting a SQLException
    //SQLE is caught in the catch block above
    //this finally block
    }
    try {
    if ((conn != null) && !(conn.isClosed()) {
    conn.commit();
    conn.close();
    }
    } catch (SQLException sqle) {
    //this isn't the place I'm getting a SQLException
    //SQLE is caught in the catch block above
    //this finally block
    }
    }//end of finally


    Yes. I've got tons of statments printing to a log file that show me
    exactly where it is failing. It is throwing the SQLException right on
    the executeUpdate().
    HightowerC, Sep 23, 2008
    #3
  4. On Tue, 23 Sep 2008 06:18:07 -0700, HightowerC wrote:

    > RDMBS is MySQL 5.0 (and MS Access. I know, I know, it wasn't my idea.)
    > It fails in both.
    >

    Thanks. I haven't used either, yet. I'm currently using Postgres, but I
    don't thing that's too important.

    > I get the connection from another method in a superclass
    > (getConnection(connectionString)). I assume it is prepared to accept
    > updates, because it works most of the time.
    >

    Understood.

    What connection, if any, is there between insertStmt and conn? Is it
    possible there's some confusion between them?

    Probably Real Gagnon's suggested change will provide the clue we're
    missing.

    > Yes. I've got tons of statments printing to a log file that show me
    > exactly where it is failing. It is throwing the SQLException right on
    > the executeUpdate().
    >

    Just checking :)


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
    Martin Gregorie, Sep 23, 2008
    #4
  5. HightowerC

    meavy

    Joined:
    Feb 7, 2009
    Messages:
    1
    Hi, i'm just facing the exactly same crazying problem !!! anyone to give solutions or couldn't HightowerC give us the way he went out of this mess ...


    thank you for responding it would be much appreciated !!!!!
    meavy, Feb 7, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sven Schimmel
    Replies:
    1
    Views:
    497
  2. =?Utf-8?B?S2FseWFu?=
    Replies:
    2
    Views:
    1,407
    =?Utf-8?B?S2FseWFu?=
    Jun 18, 2004
  3. Kal
    Replies:
    1
    Views:
    9,519
    Kevin Spencer
    Jun 21, 2004
  4. HK
    Replies:
    1
    Views:
    2,274
    Lucas Tam
    Apr 25, 2005
  5. mahesh
    Replies:
    3
    Views:
    4,686
    cb_1987
    Apr 6, 2010
Loading...

Share This Page