8 messages in com.mysql.lists.javaRE: sql warnings and JDBC
FromSent OnAttachments
Jan Kuehl20 Mar 2006 05:44 
Rhino20 Mar 2006 06:33 
Jan Kuehl20 Mar 2006 07:02 
Ronald Boettcher20 Mar 2006 07:34 
Gustitus, Paul20 Mar 2006 07:42 
Jan Kuehl20 Mar 2006 07:46 
Ronald Boettcher20 Mar 2006 08:22 
SOTL21 Mar 2006 05:50 
Subject:RE: sql warnings and JDBC
From:Gustitus, Paul (Paul@va.gov)
Date:03/20/2006 07:42:31 AM
List:com.mysql.lists.java

I would like to confirm this theory. After a recent upgrade, I began to have a number of problems with previously working code. I just rolled back to 3.1.11 from 3.1.12 and my code is working again.

Now I have to see which version my web hosting vendor is using.

Regards (and Thanks)

-----Original Message----- From: Jan Kuehl [mailto:jan.@software-tomography.com] Sent: Monday, March 20, 2006 10:02 AM To: ja@lists.mysql.com Subject: Re: sql warnings and JDBC

Rhino wrote:

----- Original Message ----- From: "Jan Kuehl" <jan.@software-tomography.com> To: <ja@lists.mysql.com> Sent: Monday, March 20, 2006 8:45 AM Subject: sql warnings and JDBC

Hi

I have changed my environment from an old 3.0.11 JDBC driver to the new 3.1.12. The old driver suppress the warnings from the mysql server which the new reports as SQLExceptions. How can I check if the SQLExceptions is a warning or an error?

Example: CREATE TABLE d(i INT AUTO_INCREMENT NOT NULL); INSERT INTO d VALUES('0'); -> ok INSERT INTO d VALUES(''); -> ok with warning = SQLException

I don't think I understand your question/problem but here's some information that _might_ be useful.

A simple way to determine what went wrong with an SQL statement is to put each SQL statement in a try block like this:

try { <your SQL statement> } catch (SQLException sql_excp) { System.err.println("SQLState: " + sql_excp.getSQLState()); System.err.println("SQLCode: " + sql_excp.getErrorCode()); System.err.println("Message: " + sql_excp.getMessage()); }

If you clarify what your concern is, perhaps someone on this list can give you a more useful answer.

Hi

Because of the missunderstanding I hope to clearify the problem with this email.

The problem is that the new driver reports warnings as SQLExceptions. For example the statement 'INSERT INTO d VALUE('')' produces a warning because '0' is the correct syntax '' is a "wrong" syntax but the server knows the meaning. The 3.0.11 JDBC driver ignores the warnings but the 3.1.12 reports the warnings as SQLException. I hope that somebody knows how I can check if the SQLException is a warning or an error. If it is an error I must handle it differently because the statement was not successfully executed. A statement with a warning was executed successfully. The SQLState/SQLCode contains no information if it is a warning or an error.