| Bug #19338 | rows handled info lost when a SQLWarning is raised. | ||
|---|---|---|---|
| Submitted: | 25 Apr 2006 16:13 | Modified: | 25 Apr 2006 16:39 |
| Reporter: | Andre Timmer | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / J | Severity: | S2 (Serious) |
| Version: | mysql-connector-java-3.1.12-bin.jar | OS: | java 1.5.0_06-b05 |
| Assigned to: | CPU Architecture: | Any | |
[25 Apr 2006 16:31]
Mark Matthews
JDBC requires that truncation on _write_ raise an exception, so the driver is acting as expected and required by the JDBC specification. If you don't want this behavior, add "jdbcCompliantTruncation=false" to your URL configuration properties.
[25 Apr 2006 16:39]
Andre Timmer
It works, thanks.

Description: Cannot get number or rows changed when a SQLWarning is thrown. So i cannot program on this (for example log how many rows are inserted)!! Maybe there is a way to do this that i am not aware of. How to repeat: String statement = null; int rows = -7; try { rows = -7; statement = "drop table if exists aat5"; rows = st.executeUpdate(statement); System.out.println("Rows: " +rows); rows = -7; statement = "create table aat5 (id integer primary key)"; rows = st.executeUpdate(statement); System.out.println("Rows: " +rows); rows = -7; statement = "insert into aat5 (id) values (1)"; rows = st.executeUpdate(statement); System.out.println("Rows: " +rows); // PRINTS 1 rows = -7; statement = "insert into aat5 (id) values ('a1')"; rows = st.executeUpdate(statement); System.out.println("Rows: " +rows); // STATEMENT IS NOT REACHED } catch (SQLWarning e) { // PRINTS -7, QUESTION IS HOW TO GET THE ROWCOUNT System.out.println("Rows: " +rows); } Suggested fix: I don't know. Maybe extend com.mysql.jdbc.SQLError ot have a method getRows(). Or a way of preventing the jdbc driver from throwing an exception. Remark: it could also be a statement that inserts or updates multiple rows.