Skip to end of metadata
Go to start of metadata

There are situations where you may want to prevent accidental or intentional write operations to a database. 

Note!

There is no way to securely prevent write operations from the client. A proper security solution must be implemented by the DBA at the server using roles and permission.

This said, depending on your JDBC Driver and the server you connect to, DbVisualizer can offer some help.

Permission Mode

Modify the connection properties and set the desired type (Development/Test/Production) and then define permissions in the SQL Commander to prevent all write operations. 

The default settings for the Production type will prompt for confirmation before doing any write operations. You can change this to Deny for extra safety. 

Note: this will only affect SQL Commander and will not prevent operations like "Alter Table" when called from a menu.

java.sql.connection.setReadOnly

Depending on the database and JDBC driver, you may be able to set the session in read-only mode by defining the connection property java.sql.connection.setReadOnly = true (see Configuring Connection Properties). 

The effect of this is not guaranteed; the server may silently ignore this setting and still operate in read/write mode.

Setting a Driver Property

Some drivers offer properties for setting read-only mode (see example below). Please refer to the driver documentation for more information.


Connection Hook

Finally, you can create a connection hook, i.e. an SQL statement that is run whenever you connect or disconnect to a database. Exactly what statement to run depends on the database.

  • No labels