yannisf
yannisf

Reputation: 6126

Oracle read-only JDBC connection

Is there a way to acquire read-only JDBC connection from an oracle database. Typically I am looking for a jdbc url parameter that will enable this, something like:

jdbc:oracle:thin:@hostname:1521:sid?readonly=true

I am using the thin driver

Upvotes: 23

Views: 23689

Answers (2)

chaos
chaos

Reputation: 681

As far as I'm aware, the thin drive will have the same permissions as the user you're connected with will have, therefore, the easiest way to acquire this is by having a user in the database which is read-only. Check the last bit of this link: http://docs.oracle.com/cd/B19306_01/java.102/b14355/apxtips.htm

Upvotes: 5

Abhijith Nagarajan
Abhijith Nagarajan

Reputation: 4030

As suggested in comments. Best is to grant the read only permissions to user accessing the database.

There is an alternative which is not suggested.

You can set the readOnly parameter in the Connection class using connection.setReadOnly.

Refer API docs for more details.

http://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html#setReadOnly(boolean)

Upvotes: 12

Related Questions