Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
package io.vertx.oracleclient;

import java.sql.ResultSet;

/**
* Represents the fetch direction hint
*/
public enum FetchDirection {

FORWARD(ResultSet.FETCH_FORWARD),
REVERSE(ResultSet.FETCH_REVERSE),
UNKNOWN(ResultSet.FETCH_UNKNOWN);

private final int type;

FetchDirection(int type) {
this.type = type;
}

public int getType() {
return type;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2022 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -50,6 +50,12 @@ public static OracleConnectOptions wrap(SqlConnectOptions options) {
private String tnsAlias;
private String tnsAdmin;

private int queryTimeout;
private int maxRows;
private FetchDirection fetchDirection;
private int fetchSize;


public OracleConnectOptions() {
super();
}
Expand All @@ -66,6 +72,10 @@ private void copyFields(OracleConnectOptions other) {
this.instanceName = other.instanceName;
this.tnsAlias = other.tnsAlias;
this.tnsAdmin = other.tnsAdmin;
this.queryTimeout = other.queryTimeout;
this.maxRows = other.maxRows;
this.fetchDirection = other.fetchDirection;
this.fetchSize = other.fetchSize;
}

public OracleConnectOptions(SqlConnectOptions options) {
Expand Down Expand Up @@ -205,6 +215,54 @@ public OracleConnectOptions setTnsAdmin(String tnsAdmin) {
return this;
}

public int getQueryTimeout() {
return queryTimeout;
}

/**
* @see java.sql.PreparedStatement#setQueryTimeout(int)
*/
public OracleConnectOptions setQueryTimeout(int queryTimeout) {
this.queryTimeout = queryTimeout;
return this;
}

public int getMaxRows() {
return maxRows;
}

/**
* @see java.sql.PreparedStatement#setMaxRows(int)
*/
public OracleConnectOptions setMaxRows(int maxRows) {
this.maxRows = maxRows;
return this;
}

public FetchDirection getFetchDirection() {
return fetchDirection;
}

/**
* @see java.sql.PreparedStatement#setFetchDirection(int)
*/
public OracleConnectOptions setFetchDirection(FetchDirection fetchDirection) {
this.fetchDirection = fetchDirection;
return this;
}

public int getFetchSize() {
return fetchSize;
}

/**
* @see java.sql.PreparedStatement#setFetchSize(int)
*/
public OracleConnectOptions setFetchSize(int fetchSize) {
this.fetchSize = fetchSize;
return this;
}

// Non-specific options

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -219,9 +219,9 @@ private void checkPending() {
private OracleCommand wrap(CommandBase cmd) {
OracleCommand action;
if (cmd instanceof SimpleQueryCommand) {
action = OracleSimpleQueryCommand.create(connection, context, (SimpleQueryCommand) cmd);
action = OracleSimpleQueryCommand.create(connection, context, (SimpleQueryCommand) cmd, options);
} else if (cmd instanceof PrepareStatementCommand) {
action = new OraclePrepareStatementCommand(connection, context, (PrepareStatementCommand) cmd);
action = new OraclePrepareStatementCommand(connection, context, (PrepareStatementCommand) cmd, options);
} else if (cmd instanceof ExtendedQueryCommand) {
action = forExtendedQuery((ExtendedQueryCommand) cmd);
} else if (cmd instanceof TxCommand) {
Expand Down Expand Up @@ -249,12 +249,12 @@ private OracleCommand forExtendedQuery(ExtendedQueryCommand cmd) {
if (rowReader != null) {
action = OracleCursorFetchCommand.create(connection, context, cmd, rowReader);
} else {
action = OracleCursorQueryCommand.create(connection, context, cmd, cmd.collector(), rr -> cursors.put(cursorId, rr));
action = OracleCursorQueryCommand.create(connection, context, cmd, cmd.collector(), rr -> cursors.put(cursorId, rr), options);
}
} else if (cmd.isBatch()) {
action = new OraclePreparedBatchQuery(connection, context, cmd, cmd.collector());
action = new OraclePreparedBatchQueryCommand(connection, context, cmd, cmd.collector(), options);
} else {
action = new OraclePreparedQueryCommand(connection, context, cmd, cmd.collector());
action = new OraclePreparedQueryCommand(connection, context, cmd, cmd.collector(), options);
}
return action;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -13,11 +13,14 @@
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.impl.ContextInternal;
import io.vertx.oracleclient.OracleConnectOptions;
import io.vertx.oracleclient.impl.Helper.SQLBlockingCodeHandler;
import io.vertx.sqlclient.impl.command.CommandBase;
import io.vertx.sqlclient.impl.command.CommandResponse;
import oracle.jdbc.OracleConnection;

import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.Flow;

import static io.vertx.oracleclient.impl.FailureUtil.sanitize;
Expand Down Expand Up @@ -89,4 +92,21 @@ public void onComplete() {
public final void fireResponse() {
response.fire();
}

protected void applyStatementOptions(Statement stmt, OracleConnectOptions connectOptions) throws SQLException {
if (connectOptions != null) {
if (connectOptions.getQueryTimeout() > 0) {
stmt.setQueryTimeout(connectOptions.getQueryTimeout());
}
if (connectOptions.getMaxRows() > 0) {
stmt.setMaxRows(connectOptions.getMaxRows());
}
if (connectOptions.getFetchDirection() != null) {
stmt.setFetchDirection(connectOptions.getFetchDirection().getType());
}
if (connectOptions.getFetchSize() > 0) {
stmt.setFetchSize(connectOptions.getFetchSize());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -38,8 +38,8 @@ public class OracleCursorQueryCommand<C, R> extends OracleQueryCommand<C, R> {
private final Collector<Row, C, R> collector;
private final QueryResultHandler<R> resultHandler;

private OracleCursorQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand<R> cmd, Collector<Row, C, R> collector, Consumer<RowReader<C, R>> store) {
super(oracleConnection, connectionContext, collector);
private OracleCursorQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand<R> cmd, Collector<Row, C, R> collector, Consumer<RowReader<C, R>> store, io.vertx.oracleclient.OracleConnectOptions connectOptions) {
super(oracleConnection, connectionContext, collector, connectOptions);
sql = cmd.sql();
fetch = cmd.fetch();
params = cmd.params();
Expand All @@ -49,8 +49,8 @@ private OracleCursorQueryCommand(OracleConnection oracleConnection, ContextInter
this.store = store;
}

public static <U, V> OracleCursorQueryCommand<U, V> create(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand<V> cmd, Collector<Row, U, V> collector, Consumer<RowReader<U, V>> store) {
return new OracleCursorQueryCommand<>(oracleConnection, connectionContext, cmd, collector, store);
public static <U, V> OracleCursorQueryCommand<U, V> create(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand<V> cmd, Collector<Row, U, V> collector, Consumer<RowReader<U, V>> store, io.vertx.oracleclient.OracleConnectOptions connectOptions) {
return new OracleCursorQueryCommand<>(oracleConnection, connectionContext, cmd, collector, store, connectOptions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -13,6 +13,7 @@
import io.vertx.core.Future;
import io.vertx.core.impl.ContextInternal;
import io.vertx.core.json.JsonArray;
import io.vertx.oracleclient.OracleConnectOptions;
import io.vertx.oracleclient.OraclePrepareOptions;
import io.vertx.sqlclient.impl.PreparedStatement;
import io.vertx.sqlclient.impl.command.PrepareStatementCommand;
Expand All @@ -25,11 +26,13 @@ public class OraclePrepareStatementCommand extends OracleCommand<PreparedStateme

private final OraclePrepareOptions options;
private final String sql;
private final OracleConnectOptions connectOptions;

public OraclePrepareStatementCommand(OracleConnection oracleConnection, ContextInternal connectionContext, PrepareStatementCommand cmd) {
public OraclePrepareStatementCommand(OracleConnection oracleConnection, ContextInternal connectionContext, PrepareStatementCommand cmd, OracleConnectOptions connectOptions) {
super(oracleConnection, connectionContext);
this.options = OraclePrepareOptions.createFrom(cmd.options());
this.sql = cmd.sql();
this.connectOptions = connectOptions;
}

@Override
Expand All @@ -56,6 +59,7 @@ private Future<PreparedStatement> prepareWithAutoGeneratedIndexes() {
keys[i] = indexes.getInteger(i);
}
try (java.sql.PreparedStatement statement = oracleConnection.prepareStatement(sql, keys)) {
applyStatementOptions(statement, connectOptions);
return new OraclePreparedStatement(sql, statement);
}
}
Expand All @@ -65,6 +69,7 @@ private Future<PreparedStatement> prepareWithAutoGeneratedIndexes() {
keys[i] = indexes.getString(i);
}
try (java.sql.PreparedStatement statement = oracleConnection.prepareStatement(sql, keys)) {
applyStatementOptions(statement, connectOptions);
return new OraclePreparedStatement(sql, statement);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -33,14 +33,14 @@

import static io.vertx.oracleclient.impl.FailureUtil.sanitize;

public class OraclePreparedBatchQuery<C, R> extends OracleQueryCommand<C, R> {
public class OraclePreparedBatchQueryCommand<C, R> extends OracleQueryCommand<C, R> {

private final String sql;
private final List<TupleInternal> listParams;
private final QueryResultHandler<R> resultHandler;

public OraclePreparedBatchQuery(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand<R> cmd, Collector<Row, C, R> collector) {
super(oracleConnection, connectionContext, collector);
public OraclePreparedBatchQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand<R> cmd, Collector<Row, C, R> collector, io.vertx.oracleclient.OracleConnectOptions connectOptions) {
super(oracleConnection, connectionContext, collector, connectOptions);
sql = cmd.sql();
listParams = cmd.paramsList();
resultHandler = cmd.resultHandler();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -33,8 +33,8 @@ public class OraclePreparedQueryCommand<C, R> extends OracleQueryCommand<C, R> {
private final PrepareOptions prepareOptions;
private final QueryResultHandler<R> resultHandler;

public OraclePreparedQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand<R> cmd, Collector<Row, C, R> collector) {
super(oracleConnection, connectionContext, collector);
public OraclePreparedQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand<R> cmd, Collector<Row, C, R> collector, io.vertx.oracleclient.OracleConnectOptions connectOptions) {
super(oracleConnection, connectionContext, collector, connectOptions);
sql = cmd.sql();
params = cmd.params();
prepareOptions = cmd.options();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -15,6 +15,7 @@
import io.vertx.core.buffer.Buffer;
import io.vertx.core.impl.ContextInternal;
import io.vertx.core.json.JsonArray;
import io.vertx.oracleclient.OracleConnectOptions;
import io.vertx.oracleclient.OraclePrepareOptions;
import io.vertx.oracleclient.data.Blob;
import io.vertx.oracleclient.impl.Helper;
Expand All @@ -39,10 +40,12 @@
public abstract class OracleQueryCommand<C, R> extends OracleCommand<Boolean> {

private final Collector<Row, C, R> collector;
private final OracleConnectOptions connectOptions;

protected OracleQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, Collector<Row, C, R> collector) {
protected OracleQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, Collector<Row, C, R> collector, io.vertx.oracleclient.OracleConnectOptions connectOptions) {
super(oracleConnection, connectionContext);
this.collector = collector;
this.connectOptions = connectOptions;
}

@Override
Expand Down Expand Up @@ -126,6 +129,7 @@ private Future<OraclePreparedStatement> prepare(Connection conn, OraclePrepareOp
ps = conn.prepareStatement(query());
}

applyStatementOptions(ps, connectOptions);
fillStatement(ps, conn);

prom.complete(ps.unwrap(OraclePreparedStatement.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -29,14 +29,14 @@ public class OracleSimpleQueryCommand<C, R> extends OracleQueryCommand<C, R> {
private final String sql;
private final QueryResultHandler<R> resultHandler;

private OracleSimpleQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, SimpleQueryCommand<R> cmd, Collector<Row, C, R> collector) {
super(oracleConnection, connectionContext, collector);
private OracleSimpleQueryCommand(OracleConnection oracleConnection, ContextInternal connectionContext, SimpleQueryCommand<R> cmd, Collector<Row, C, R> collector, io.vertx.oracleclient.OracleConnectOptions connectOptions) {
super(oracleConnection, connectionContext, collector, connectOptions);
sql = cmd.sql();
resultHandler = cmd.resultHandler();
}

public static <U> OracleSimpleQueryCommand<?, U> create(OracleConnection oracleConnection, ContextInternal connectionContext, SimpleQueryCommand<U> cmd) {
return new OracleSimpleQueryCommand<>(oracleConnection, connectionContext, cmd, cmd.collector());
public static <U> OracleSimpleQueryCommand<?, U> create(OracleConnection oracleConnection, ContextInternal connectionContext, SimpleQueryCommand<U> cmd, io.vertx.oracleclient.OracleConnectOptions connectOptions) {
return new OracleSimpleQueryCommand<>(oracleConnection, connectionContext, cmd, cmd.collector(), connectOptions);
}

@Override
Expand Down