Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to ensure a read-only table will never be locked?

 
Rob Chung
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a static table that should be read only. In order for this table never to be locked, I coded:
myConnection.prepareStatement(thePreparedSQLStmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
Is this the correct way to prevent the table ever be locked?
Thanks in advance.
 
Napa Sreedhar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you want your table to read only? Database level or application level?
 
Rob Chung
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be useful to know both - at database level and application level.
I noticed that you can do setReadOnly with a connection. But I am using the same connection to write to other tables.
I am using Microsoft SQL server. I can't find any property in the database in which I can make the table read-only.
Thanks!
 
Praveen Balaji
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it SQL Server 2000 or SQLServer 7.0? The database can be made read-only manually.
 
Daniel Dunleavy
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do not give update/insert/delete access for that table to IDs used to access the datebase
obviously it would be best to seperate the read only tables into a seperate tablespace from the tables which are being updated.
Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic