Skip to content

Commit 7fb7c87

Browse files
Useful error message when V$OPEN_CURSOR is not accessible
1 parent 1c0740b commit 7fb7c87

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/test/java/oracle/r2dbc/util/SharedConnectionFactory.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.r2dbc.spi.ConnectionFactoryMetadata;
2828
import io.r2dbc.spi.ConnectionMetadata;
2929
import io.r2dbc.spi.IsolationLevel;
30+
import io.r2dbc.spi.R2dbcException;
3031
import io.r2dbc.spi.Statement;
3132
import io.r2dbc.spi.ValidationDepth;
3233
import org.reactivestreams.Publisher;
@@ -38,6 +39,8 @@
3839
import java.util.concurrent.CompletionStage;
3940
import java.util.concurrent.atomic.AtomicReference;
4041

42+
import static oracle.r2dbc.DatabaseConfig.user;
43+
4144
/**
4245
* <p>
4346
* A {@link ConnectionFactory} which caches a single connection that is
@@ -176,9 +179,17 @@ private static Publisher<String> queryOpenCursors(Connection connection) {
176179
.execute())
177180
.flatMapMany(result ->
178181
result.map((row, metadata) ->
179-
row.get("sql_text", String.class)));
180-
// Don't count the v$open_cursor query
181-
//.filter();
182+
row.get("sql_text", String.class)))
183+
.onErrorMap(R2dbcException.class, r2dbcException ->
184+
// Handle ORA-00942
185+
r2dbcException.getErrorCode() == 942
186+
? new RuntimeException(
187+
"V$OPEN_CUROSR is not accessible to the test user. " +
188+
"Grant access as SYSDBA with: " +
189+
"\"GRANT SELECT ON v_$open_cursor TO "+user()+"\", " +
190+
"or disable open cursor checks with: " +
191+
" -Doracle.r2bdc.disableCursorCloseVerification=true")
192+
: r2dbcException);
182193
}
183194

184195
/**

0 commit comments

Comments
 (0)