Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 901
yannisf Avatar asked Nov 29 '13 14:11

yannisf


2 Answers

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)

like image 131
Abhijith Nagarajan Avatar answered Oct 14 '22 15:10

Abhijith Nagarajan


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

like image 29
chaos Avatar answered Oct 14 '22 17:10

chaos