ReadOnlyModeAwareConnection extends DelegatingConnection { @Override public Statement createStatement() throws SQLException { Statement statement = super.createStatement(); return createProxy(statement); } ReadOnlyModeAwareConnection(Connection connection, ReadOnlyModeStatus status); @Override Statement createStatement(); @Override PreparedStatement prepareStatement(String sql); @Override CallableStatement prepareCall(String sql); @Override Statement createStatement(int resultSetType, int resultSetConcurrency); @Override PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency); @Override CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency); @Override Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability); @Override PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability); @Override CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability); @Override PreparedStatement prepareStatement(String sql, int autoGeneratedKeys); @Override PreparedStatement prepareStatement(String sql, int[] columnIndexes); @Override PreparedStatement prepareStatement(String sql, String[] columnNames);  }
@Test public void testStatementsAreReadOnlyModeAware() throws SQLException { final ReadOnlyModeAwareConnection cnx = new ReadOnlyModeAwareConnection(mockedConnection, readOnlyModeStatus); assertIsReadOnlyModeAware(cnx.createStatement()); assertIsReadOnlyModeAware(cnx.createStatement(0, 0)); assertIsReadOnlyModeAware(cnx.createStatement(0, 0, 0)); }