You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Alain Kuchta <al...@etegent.com> on 2012/08/31 15:59:20 UTC

Get a "read-only" connection using Derby EmbeddedDataSource40

Hello all,

Does anyone know of a way to establish a "read-only" connection/datasource when using embedded derby access?

To give some context, I am making a tool to do some transfer from a "source" database to a "target" database. There should be no alterations made to the source whatsoever. Obviously, prudent code-writing could ensure this, however, if possible, I would like to further safeguard against accidental data alterations by making the connection to the "source" database read-only, so that I would receive and exception or some other kind of error if I accidentally tried to alter it. I know that result sets can be read only. But that does not fulfill my need entirely.

Thanks,

Alain Kuchta

Re: Get a "read-only" connection using Derby EmbeddedDataSource40

Posted by david myers <da...@gmail.com>.
Alain.

Have you though about using the 'roles' that are available.

Create a role that has 'read only access', then add your user to that 
role. This is the link to the page in the docs.
http://db.apache.org/derby/docs/10.9/ref/rrefcreaterole.html

Then when you log in you log in a that specified 'read only' user. You 
can hard code this into the interface, and give a menu item to enable 
users to log in at a 'higher' level.

Also you can hook your derby into LDAP or other directory name service, 
and use a 'non priveleged user' from there.

David.

On 31/08/12 17:25, Alain Kuchta wrote:
>
> Thank you for bringing this  to my attention.
>
> *From:*Katherine Marsden [mailto:kmarsdenderby@sbcglobal.net]
> *Sent:* Friday, August 31, 2012 11:23 AM
> *To:* Derby Discussion
> *Subject:* Re: Get a "read-only" connection using Derby 
> EmbeddedDataSource40
>
> On 8/31/2012 7:05 AM, Alain Kuchta wrote:
>
>     Hello all,
>
>     I've actually found an answer to my own question in the Derby
>     Reference Manual.
>
>     The java.sql.Connection method "setReadOnly(boolean)" is supported
>     and performs as I desired.
>
>     Perhaps someone else will found this snippet useful.
>
>
> One word of caution: While Connection.setReadOnly works fine for 
> Embedded.   There is a long standing  issue with the call with Client:
> https://issues.apache.org/jira/browse/DERBY-911
>


RE: Get a "read-only" connection using Derby EmbeddedDataSource40

Posted by Alain Kuchta <al...@etegent.com>.
Thank you for bringing this  to my attention.

From: Katherine Marsden [mailto:kmarsdenderby@sbcglobal.net]
Sent: Friday, August 31, 2012 11:23 AM
To: Derby Discussion
Subject: Re: Get a "read-only" connection using Derby EmbeddedDataSource40

On 8/31/2012 7:05 AM, Alain Kuchta wrote:
Hello all,

I've actually found an answer to my own question in the Derby Reference Manual.

The java.sql.Connection method "setReadOnly(boolean)" is supported and performs as I desired.

Perhaps someone else will found this snippet useful.


One word of caution: While Connection.setReadOnly works fine for Embedded.   There is a long standing  issue with the call with Client:
https://issues.apache.org/jira/browse/DERBY-911


Re: Get a "read-only" connection using Derby EmbeddedDataSource40

Posted by Katherine Marsden <km...@sbcglobal.net>.
On 8/31/2012 7:05 AM, Alain Kuchta wrote:
>
> Hello all,
>
> I've actually found an answer to my own question in the Derby 
> Reference Manual.
>
> The java.sql.Connection method "setReadOnly(boolean)" is supported and 
> performs as I desired.
>
> Perhaps someone else will found this snippet useful.
>

One word of caution: While Connection.setReadOnly works fine for 
Embedded.   There is a long standing  issue with the call with Client:
https://issues.apache.org/jira/browse/DERBY-911



RE: Get a "read-only" connection using Derby EmbeddedDataSource40

Posted by Alain Kuchta <al...@etegent.com>.
Hello all,

I've actually found an answer to my own question in the Derby Reference Manual.

The java.sql.Connection method "setReadOnly(boolean)" is supported and performs as I desired.

Perhaps someone else will found this snippet useful.

Thanks,

Alain Kuchta

From: Alain Kuchta [mailto:alain.kuchta@etegent.com]
Sent: Friday, August 31, 2012 9:59 AM
To: Derby Discussion
Subject: Get a "read-only" connection using Derby EmbeddedDataSource40

Hello all,

Does anyone know of a way to establish a "read-only" connection/datasource when using embedded derby access?

To give some context, I am making a tool to do some transfer from a "source" database to a "target" database. There should be no alterations made to the source whatsoever. Obviously, prudent code-writing could ensure this, however, if possible, I would like to further safeguard against accidental data alterations by making the connection to the "source" database read-only, so that I would receive and exception or some other kind of error if I accidentally tried to alter it. I know that result sets can be read only. But that does not fulfill my need entirely.

Thanks,

Alain Kuchta