Package org.pjdbc.drivers
Class ReadonlyDriver
java.lang.Object
org.pjdbc.sql.AbstractDriver
org.pjdbc.sql.AbstractProxyDriver
org.pjdbc.drivers.ReadonlyDriver
- All Implemented Interfaces:
Driver
@DriverCapability(prefix="readonly",
description="Enforces read-only database access",
capabilities={"security","filtering"})
@DriverParameter(name="allowDDL",type=BOOLEAN,description="Allow DDL statements (CREATE, ALTER, DROP)",defaultValue="false") @DriverParameter(name="allowDML",type=BOOLEAN,description="Allow DML statements (INSERT, UPDATE, DELETE)",defaultValue="false") @DriverParameter(name="message",type=STRING,description="Custom error message for blocked operations")
public class ReadonlyDriver
extends AbstractProxyDriver
ReadonlyDriver enforces read-only database access by blocking write operations.
URL format: jdbc:readonly[param=value,...]:jdbc:target:...
Blocked operations (by default):
- DML: INSERT, UPDATE, DELETE, MERGE, UPSERT, REPLACE, TRUNCATE
- DDL: CREATE, ALTER, DROP, RENAME
- DCL: GRANT, REVOKE
- TCL: (transactions are allowed)
Example URLs:
jdbc:readonly:jdbc:postgresql://localhost/mydb jdbc:readonly[allowDDL=true]:jdbc:postgresql://localhost/mydb jdbc:readonly[message=No writes allowed in reporting mode]:jdbc:mysql://localhost/db
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration holder for readonly parameters. -
Driver Parameters
URL format:
jdbc:readonly[param=value,...]:<target-url>Parameter Type Default Constraints Description allowDDLboolean false- Allow DDL statements (CREATE, ALTER, DROP) allowDMLboolean false- Allow DML statements (INSERT, UPDATE, DELETE) messagestring - - Custom error message for blocked operations Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptsSubName(String subname) protected booleanacceptsSubProtocol(String subprotocol) connect(String url, Properties info) protected CallableStatementproxyCallableStatement(CallableStatement delegate, Connection conn) protected ConnectionproxyConnection(Connection delegate, String url, Properties info, Driver driver) protected PreparedStatementproxyPreparedStatement(PreparedStatement delegate, Connection conn) protected StatementproxyStatement(Statement delegate, Connection conn) Methods inherited from class org.pjdbc.sql.AbstractProxyDriver
getPropertyInfo, isCompositionValidationEnabled, isValidateParametersEnabled, proxyCallableStatement, proxyConnection, proxyConnection, proxyPreparedStatement, proxyResultSetMethods inherited from class org.pjdbc.sql.AbstractDriver
acceptsProtocol, acceptsURL, getMajorVersion, getMinorVersion, getParentLogger, getUrlParameter, getUrlParameter, getUrlParameters, jdbcCompliant, parseUrl, protocol, subname, subprotocol, validateParameters
-
Constructor Details
-
ReadonlyDriver
public ReadonlyDriver()
-
-
Method Details
-
acceptsSubProtocol
- Specified by:
acceptsSubProtocolin classAbstractDriver
-
acceptsSubName
- Overrides:
acceptsSubNamein classAbstractProxyDriver
-
connect
- Specified by:
connectin interfaceDriver- Overrides:
connectin classAbstractProxyDriver- Throws:
SQLException
-
proxyConnection
protected Connection proxyConnection(Connection delegate, String url, Properties info, Driver driver) throws SQLException - Overrides:
proxyConnectionin classAbstractProxyDriver- Throws:
SQLException
-
proxyStatement
- Overrides:
proxyStatementin classAbstractProxyDriver- Throws:
SQLException
-
proxyPreparedStatement
protected PreparedStatement proxyPreparedStatement(PreparedStatement delegate, Connection conn) throws SQLException - Overrides:
proxyPreparedStatementin classAbstractProxyDriver- Throws:
SQLException
-
proxyCallableStatement
protected CallableStatement proxyCallableStatement(CallableStatement delegate, Connection conn) throws SQLException - Overrides:
proxyCallableStatementin classAbstractProxyDriver- Throws:
SQLException
-