java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed (1 reply)

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.
Submitted by programmer on Tue, 08/12/2008 - 11:02.

I am using MySQL Connector/J 5.1.6, and I've got the following exception in my application:

java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed.

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)

at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1516)

at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485)

at com.mysql.jdbc.RowDataDynamic.close(RowDataDynamic.java:195)

at com.mysql.jdbc.ResultSetImpl.realClose(ResultSetImpl.java:7473)

at com.mysql.jdbc.ResultSetImpl.close(ResultSetImpl.java:881)

After looking at code in MySQL driver I see that driver tries to execute statement:

stmt.executeUpdate("SET net_write_timeout=" + oldValue);

But if transaction is read only (as in my case), this code will throw an exception. I consider this is a bug in the MySQL driver since I do not expect any update statements when I am closing result set.

Should I post a bug report for this or there is something I missed?

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.