Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBC: exception on calling Connection.setReadOnly #2818

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

JDBC: exception on calling Connection.setReadOnly #2818

monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working Client interfaces normal

Comments

@monetdb-team
Copy link

Date: 2011-06-05 22:35:41 +0200
From: Martin Weindel <>
To: clients devs <>
Version: 11.3.3 (Apr2011-SP1) [obsolete]

Last updated: 2011-07-29 10:52:45 +0200

Comment 15833

Date: 2011-06-05 22:35:41 +0200
From: Martin Weindel <>

User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.71 Safari/534.24
Build Identifier:

If you call MonetConnection.setReadOnly(boolean) and autocommit is turned off, a SQLException is thrown.
As this call of setReadOnly is done be a framework I'm using, I cannot avoid it easily.

Reproducible: Always

Steps to Reproduce:

  1. getConnection()
  2. call MonetConnection.setAutoCommit(false)
  3. call MonetConnection.setReadOnly(false)

The understanding of setReadOnly/isReadOnly in MonetConnection seems to be a little odd to me, if I read its JavaDoc: "MonetDB doesn't support writable ResultSets, hence an SQLWarning is generated if attempted to set to false here."
But setReadOnly has nothing to do with resultsets directly.

The JDBC specification does not specify this method explicitly, but the JavaDoc of java.lang.Connection says "Puts this connection in read-only mode as a hint to the driver to enable database optimizations.", and more importantly: "Throws:
SQLException - SQLException if a database access error occurs or this method is called on a closed connection"

This means:

  1. Calling setReadOnly is only a hint and should not throw an exception on normal circumstances
  2. MonetConnection should behave like may others JDBC drivers and just ignore the call of setReadOnly (you can check if the connection is closed if you want to be perfect specification conform)
  3. isReadOnly should return false and not true as in MonetConnection, as the connection to the MonetDB can still execute write statements.

Comment 15834

Date: 2011-06-06 10:57:40 +0200
From: @grobian

Thank you for your concise report.

You get an exception, because of this phrase in the Javadoc:

Note: This method cannot be called during a transaction.

I understand that the framework you use does not expect this, so I'm lenient towards changing this behaviour, essentially ignoring the note.

Comment 15835

Date: 2011-06-06 11:20:41 +0200
From: @grobian

Changeset 318b2593135b made by Fabian Groffen fabian@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=318b2593135b

Changeset description:

JDBC: don't throw an exception from setReadOnly

Bug #2818, don't throw an exception from Connection.setReadOnly when
autocommit is disabled.  Since setReadOnly is not implemented at all
anyway, don't make it throw exceptions that may upset frameworks that
call these methods just to be sure.

Comment 15836

Date: 2011-06-06 11:20:42 +0200
From: @grobian

Changeset ccf366781fc3 made by Fabian Groffen fabian@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=ccf366781fc3

Changeset description:

JDBC: properly advertise Connection read-only mode

JDBC's Connection read-only mode appears to be just a hint to the driver
to enable certain optimisations, if possible.  It has nothing to do with
being able to write to the database (or make modifications).  Hence, a
Connection with MonetDB is never read-only, and setReadOnly should only
emit a warning when called with true.

Thanks to Martin Weindel for pointing this out in bug #2818.

Comment 15837

Date: 2011-06-06 11:21:43 +0200
From: @grobian

The next release should include the fixes you need. Thanks.

Comment 16009

Date: 2011-07-29 10:52:45 +0200
From: @sjoerdmullender

The Apr2011-SP2 bugfix release is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Client interfaces normal
Projects
None yet
Development

No branches or pull requests

2 participants