SQLException: General Error

H

HightowerC

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.
 
M

Martin Gregorie

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?
 
H

HightowerC

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().
 
M

Martin Gregorie

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 :)
 
Joined
Feb 7, 2009
Messages
1
Reaction score
0
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 !!!!!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top